CRM-13089 - Add unit test for a creating field with a specific "name"
authorTim Otten <totten@civicrm.org>
Fri, 9 Aug 2013 22:36:19 +0000 (15:36 -0700)
committerTim Otten <totten@civicrm.org>
Fri, 9 Aug 2013 22:39:39 +0000 (15:39 -0700)
----------------------------------------
* CRM-13089: CRM_Core_BAO_CustomField::create overrides user-defined name parameter values
  http://issues.civicrm.org/jira/browse/CRM-13089

tests/phpunit/CRM/Core/BAO/CustomFieldTest.php

index 6d85f26f92e889324aaf88e9d0e14b65b49b472c..43145328086716079f1fedda4b0f4dfbd6e0654d 100644 (file)
@@ -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(