Skip to content

Commit

Permalink
CRM-18469, CRM-17984 - getTree regression on multiple integers separa…
Browse files Browse the repository at this point in the history
…ted by the cnrtl char
  • Loading branch information
eileenmcnaughton committed Apr 27, 2016
1 parent 8f27696 commit 35e83f3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
7 changes: 6 additions & 1 deletion CRM/Core/BAO/CustomGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,12 @@ public static function getTree(
$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));
}
}
}

Expand Down
21 changes: 20 additions & 1 deletion tests/phpunit/CRM/Core/BAO/CustomGroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,25 @@ public function testGetTreeContactSubType() {
$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.
*/
Expand All @@ -84,7 +103,7 @@ public function testGetTreeActivitySubType() {
}

/**
* Test retrieve() with Empty Params
* Test retrieve() with Empty Params.
*/
public function testRetrieveEmptyParams() {
$params = array();
Expand Down

0 comments on commit 35e83f3

Please sign in to comment.