From f8a3cd29aba9ddf62e6f00b1ccf22a3d53952f73 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 2 Sep 2013 18:19:09 -0700 Subject: [PATCH] CRM-13027 - More detail for test ---------------------------------------- * CRM-13027: Default getFields returns irrelevant custom-data fields http://issues.civicrm.org/jira/browse/CRM-13027 --- tests/phpunit/api/v3/CustomFieldTest.php | 34 ++++++++++++++++-------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/tests/phpunit/api/v3/CustomFieldTest.php b/tests/phpunit/api/v3/CustomFieldTest.php index 092a12f3b3..1ebbfac91c 100644 --- a/tests/phpunit/api/v3/CustomFieldTest.php +++ b/tests/phpunit/api/v3/CustomFieldTest.php @@ -408,19 +408,29 @@ class api_v3_CustomFieldTest extends CiviUnitTestCase { } // Add some fields - $contactGroup = $this->customGroupCreate(array('extends' => 'Contact', 'title' => 'test_group')); + $contactGroup = $this->customGroupCreate(array('extends' => 'Contact', 'title' => 'test_group_c')); $contactField = $this->customFieldCreate(array('custom_group_id' => $contactGroup['id'], 'label' => 'For Contacts')); - $activityGroup = $this->customGroupCreate(array('extends' => 'Activity', 'title' => 'test_group')); + $indivGroup = $this->customGroupCreate(array('extends' => 'Individual', 'title' => 'test_group_i')); + $indivField = $this->customFieldCreate(array('custom_group_id' => $indivGroup['id'], 'label' => 'For Individuals')); + $activityGroup = $this->customGroupCreate(array('extends' => 'Activity', 'title' => 'test_group_a')); $activityField = $this->customFieldCreate(array('custom_group_id' => $activityGroup['id'], 'label' => 'For Activities')); - // getfields reports exactly one custom field for each entity - foreach (array('Contact', 'Individual', 'Organization') as $entity) { - $this->assertEquals( - array('custom_' . $contactField['id']), - $this->getCustomFieldKeys($this->callAPISuccess($entity, 'getfields', array())), - 'Contact custom fields' - ); - } + // Check getfields + $this->assertEquals( + array('custom_' . $contactField['id'], 'custom_' . $indivField['id']), + $this->getCustomFieldKeys($this->callAPISuccess('Contact', 'getfields', array())), + 'Contact custom fields' + ); + $this->assertEquals( + array('custom_' . $contactField['id'], 'custom_' . $indivField['id']), + $this->getCustomFieldKeys($this->callAPISuccess('Individual', 'getfields', array())), + 'Individual custom fields' + ); + $this->assertEquals( + array('custom_' . $contactField['id']), + $this->getCustomFieldKeys($this->callAPISuccess('Organization', 'getfields', array())), + 'Organization custom fields' + ); $this->assertEquals( array('custom_' . $activityField['id']), $this->getCustomFieldKeys($this->callAPISuccess('Activity', 'getfields', array())), @@ -439,7 +449,9 @@ class api_v3_CustomFieldTest extends CiviUnitTestCase { $isCustom = function($key) { return preg_match('/^custom_/', $key); }; - return array_values(array_filter(array_keys($getFieldsResult['values']), $isCustom)); + $r = array_values(array_filter(array_keys($getFieldsResult['values']), $isCustom)); + sort($r); + return $r; } } -- 2.25.1