From 2bb43fd37224c69374bd75058f1869d697a8cd74 Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Wed, 27 Apr 2016 20:13:41 +1200 Subject: [PATCH] Further custom tree regression fix, where the label does not match the name the name is the key to use --- CRM/Core/BAO/CustomGroup.php | 2 +- tests/phpunit/CRM/Core/BAO/CustomGroupTest.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index 268d90110f..9a4937e812 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -642,7 +642,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 5c290fbfaa..74cd8e335c 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomGroupTest.php @@ -57,14 +57,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')); -- 2.25.1