From: eileenmcnaugton Date: Wed, 27 Apr 2016 08:13:41 +0000 (+1200) Subject: Further custom tree regression fix, where the label does not match the name the name... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=325fa9658175bd9c91d4ae82a19e6f461eaab38b;p=civicrm-core.git Further custom tree regression fix, where the label does not match the name the name is the key to use --- diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index 837bde7f1b..0d76d4672f 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -658,7 +658,7 @@ ORDER BY civicrm_custom_group.weight, throw new CRM_Core_Exception('Invalid Entity Filter'); } $subTypes = civicrm_api3('Contact', 'getoptions', array('field' => 'contact_sub_type')); - if (!in_array($subType, $subTypes['values'])) { + if (!isset($subTypes['values'][$subType])) { // Same comments about fail hard as above. throw new CRM_Core_Exception('Invalid Filter'); } diff --git a/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php b/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php index 3d35f44251..efd65a5207 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php @@ -53,14 +53,14 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase { * inconsistency. */ public function testGetTreeContactSubType() { - $this->callAPISuccess('ContactType', 'create', array('name' => 'Big Bank', 'parent_id' => 'Organization')); - $customGroup = $this->CustomGroupCreate(array('extends' => 'Organization', 'extends_entity_column_value' => array('Big Bank'))); + $this->callAPISuccess('ContactType', 'create', array('name' => 'Big Bank', 'label' => 'biggee', 'parent_id' => 'Organization')); + $customGroup = $this->CustomGroupCreate(array('extends' => 'Organization', 'extends_entity_column_value' => array('Big_Bank'))); $customField = $this->customFieldCreate(array('custom_group_id' => $customGroup['id'])); - $result1 = CRM_Core_BAO_CustomGroup::getTree('Organization', NULL, NULL, NULL, array('Big Bank')); + $result1 = CRM_Core_BAO_CustomGroup::getTree('Organization', NULL, NULL, NULL, array('Big_Bank')); $this->assertEquals('Custom Field', $result1[$customGroup['id']]['fields'][$customField['id']]['label']); - $result = CRM_Core_BAO_CustomGroup::getTree('Organization', NULL, NULL, NULL, CRM_Core_DAO::VALUE_SEPARATOR . 'Big Bank' . CRM_Core_DAO::VALUE_SEPARATOR); + $result = CRM_Core_BAO_CustomGroup::getTree('Organization', NULL, NULL, NULL, CRM_Core_DAO::VALUE_SEPARATOR . 'Big_Bank' . CRM_Core_DAO::VALUE_SEPARATOR); $this->assertEquals($result1, $result); - $result = CRM_Core_BAO_CustomGroup::getTree('Organization', NULL, NULL, NULL, 'Big Bank'); + $result = CRM_Core_BAO_CustomGroup::getTree('Organization', NULL, NULL, NULL, 'Big_Bank'); $this->assertEquals($result1, $result); try { CRM_Core_BAO_CustomGroup::getTree('Organization', NULL, NULL, NULL, array('Small Kind Bank'));