From eebb53dfc907340788d90375cdc46dbfc49fe42b Mon Sep 17 00:00:00 2001 From: Johan Vervloet Date: Mon, 3 Nov 2014 21:50:41 +0100 Subject: [PATCH] CRM-15542 - Unit test. ---------------------------------------- * CRM-15542: The api ignores option_group_id when creating a new custom_field. https://issues.civicrm.org/jira/browse/CRM-15542 --- tests/phpunit/api/v3/CustomFieldTest.php | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/phpunit/api/v3/CustomFieldTest.php b/tests/phpunit/api/v3/CustomFieldTest.php index ef86546086..293988a78d 100644 --- a/tests/phpunit/api/v3/CustomFieldTest.php +++ b/tests/phpunit/api/v3/CustomFieldTest.php @@ -261,6 +261,35 @@ class api_v3_CustomFieldTest extends CiviUnitTestCase { $this->assertEquals(0, $optionValueCount); } + /** + * Test custom field with existing option group + */ + function testCustomFieldExistingOptionGroup() { + $customGroup = $this->customGroupCreate(array('extends' => 'Organization', 'title' => 'test_group')); + $params = array( + 'custom_group_id' => $customGroup['id'], + // Just to say something: + 'label' => 'Organization Gender', + 'html_type' => 'Select', + 'data_type' => 'Int', + 'weight' => 4, + 'is_required' => 1, + 'is_searchable' => 0, + 'is_active' => 1, + // Option group id 3: gender + 'option_group_id' => 3, + ); + + $customField = $this->callAPISuccess('custom_field', 'create', $params); + $this->assertNotNull($customField['id']); + $optionGroupID = $this->callAPISuccess('custom_field', 'getvalue', array( + 'id' => $customField['id'], + 'return' => 'option_group_id', + )); + + $this->assertEquals($optionGroupID,3); + } + /** * Test custom field get works & return param works -- 2.25.1