From: eileenmcnaugton Date: Wed, 27 Apr 2016 07:37:02 +0000 (+1200) Subject: CRM-18469, CRM-17984 - getTree regression on multiple integers separated by the cnrtl... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=35e83f391d6380159fac9ae1891117622093be4a;p=civicrm-core.git CRM-18469, CRM-17984 - getTree regression on multiple integers separated by the cnrtl char --- diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index d56c7ed18b..837bde7f1b 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -363,7 +363,12 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { $subTypes = array(); } else { - $subTypes = explode(',', $subTypes); + if (stristr(',', $subTypes)) { + $subTypes = explode(',', $subTypes); + } + else { + $subTypes = explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($subTypes, CRM_Core_DAO::VALUE_SEPARATOR)); + } } } diff --git a/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php b/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php index ac6962f058..3d35f44251 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php @@ -72,6 +72,25 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase { $this->fail('There is no such thing as a small kind bank'); } + /** + * Test calling getTree with contact subtype data. + * + * Note that the function seems to support a range of formats so 3 are tested. Yay for + * inconsistency. + */ + public function testGetTreeCampaignSubType() { + $this->campaignCreate(); + $this->campaignCreate(); + $customGroup = $this->CustomGroupCreate(array( + 'extends' => 'Campaign', + 'extends_entity_column_value' => '12' + )); + $customField = $this->customFieldCreate(array('custom_group_id' => $customGroup['id'])); + $result1 = CRM_Core_BAO_CustomGroup::getTree('Campaign', NULL, NULL, NULL, '12'); + $this->assertEquals('Custom Field', $result1[$customGroup['id']]['fields'][$customField['id']]['label']); + $this->customGroupDelete($customGroup['id']); + } + /** * Test calling getTree with contact subtype data. */ @@ -84,7 +103,7 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase { } /** - * Test retrieve() with Empty Params + * Test retrieve() with Empty Params. */ public function testRetrieveEmptyParams() { $params = array();