From 43ff319625fb5cf748032f3cf4131a559cd18475 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 9 Aug 2013 15:36:19 -0700 Subject: [PATCH] CRM-13089 - Add unit test for a creating field with a specific "name" ---------------------------------------- * CRM-13089: CRM_Core_BAO_CustomField::create overrides user-defined name parameter values http://issues.civicrm.org/jira/browse/CRM-13089 --- .../phpunit/CRM/Core/BAO/CustomFieldTest.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/phpunit/CRM/Core/BAO/CustomFieldTest.php b/tests/phpunit/CRM/Core/BAO/CustomFieldTest.php index 6d85f26f92..4314532808 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomFieldTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomFieldTest.php @@ -72,6 +72,27 @@ class CRM_Core_BAO_CustomFieldTest extends CiviUnitTestCase { Custom::deleteGroup($customGroup); } + function testCreateCustomfieldName() { + $customGroup = Custom::createGroup(array(), 'Individual'); + $fields = array( + 'label' => 'testFld 2', + 'name' => 'special_fldlname', + 'data_type' => 'String', + 'html_type' => 'Text', + 'custom_group_id' => $customGroup->id, + ); + $customField = CRM_Core_BAO_CustomField::create($fields); + $customFieldID = $this->assertDBNotNull('CRM_Core_DAO_CustomField', $customGroup->id, 'id', 'custom_group_id', + 'Database check for created CustomField.' + ); + $dbFieldName = $this->assertDBNotNull('CRM_Core_DAO_CustomField', $customFieldID, 'name', 'id', 'Database check for edited CustomField.'); + $this->assertEquals($fields['name'], $dbFieldName, + "Column name set as specified"); + + Custom::deleteGroup($customGroup); + } + + function testGetFields() { $customGroup = Custom::createGroup(array(), 'Individual'); $fields = array( -- 2.25.1