[NFC] CRM-19033 improve standardisation of tests
authoreileen <emcnaughton@wikimedia.org>
Wed, 6 Jul 2016 05:05:19 +0000 (17:05 +1200)
committereileen <emcnaughton@wikimedia.org>
Wed, 6 Jul 2016 05:24:41 +0000 (17:24 +1200)
NB jenkins is doing wierd things here so trying a small subset to see what jenkins does

tests/phpunit/CRM/Core/BAO/CustomGroupTest.php
tests/phpunit/CRM/Core/BAO/CustomValueTableMultipleTest.php

index aeadf78e5aa8dcf3aa2771e784d892be867f7990..3d691d096f7c398cb06a068fd5f765d5380f4877 100644 (file)
@@ -166,9 +166,9 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase {
    * Test retrieve()
    */
   public function testRetrieve() {
-    $customGrouptitle = 'My Custom Group';
+    $customGroupTitle = 'Custom Group';
     $groupParams = array(
-      'title' => $customGrouptitle,
+      'title' => $customGroupTitle,
       'name' => 'My_Custom_Group',
       'style' => 'Tab',
       'extends' => 'Individual',
@@ -177,43 +177,28 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase {
       'is_active' => 1,
       'collapse_display' => 1,
       'weight' => 2,
-      'version' => 3,
-    );
-
-    $customGroup = Custom::createGroup($groupParams);
-    $customGroupId = $customGroup->id;
-
-    $params = array('id' => $customGroupId);
-    $customGroup = CRM_Core_BAO_CustomGroup::retrieve($params, $dafaults);
-    $dbCustomGroupTitle = $this->assertDBNotNull('CRM_Core_DAO_CustomGroup', $customGroupId, 'title', 'id',
-      'Database check for custom group record.'
     );
 
-    $this->assertEquals($customGrouptitle, $dbCustomGroupTitle);
-    //check retieve values
-    unset($groupParams['version']);
-    $this->assertAttributesEquals($groupParams, $dafaults);
+    $customGroup = $this->customGroupCreate($groupParams);
 
-    //cleanup DB by deleting customGroup
-    Custom::deleteGroup($customGroup);
+    $this->getAndCheck($groupParams, $customGroup['id'], 'CustomGroup');
   }
 
   /**
    * Test setIsActive()
    */
   public function testSetIsActive() {
-    $customGrouptitle = 'My Custom Group';
+    $customGroupTitle = 'My Custom Group';
     $groupParams = array(
-      'title' => $customGrouptitle,
+      'title' => $customGroupTitle,
       'name' => 'my_custom_group',
       'style' => 'Tab',
       'extends' => 'Individual',
       'is_active' => 0,
-      'version' => 3,
     );
 
-    $customGroup = Custom::createGroup($groupParams);
-    $customGroupId = $customGroup->id;
+    $customGroup = $this->customGroupCreate($groupParams);
+    $customGroupId = $customGroup['id'];
 
     //update is_active
     $result = CRM_Core_BAO_CustomGroup::setIsActive($customGroupId, TRUE);
@@ -224,8 +209,8 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase {
     $this->assertDBCompareValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'is_active', 'id', 1,
       'Database check for custom group is_active field.'
     );
-    //cleanup DB by deleting customGroup
-    Custom::deleteGroup($customGroup);
+
+    $this->customGroupDelete($customGroup['id']);
   }
 
   /**
@@ -238,7 +223,7 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase {
   }
 
   /**
-   * Test getGroupDetail() with Inalid Params
+   * Test getGroupDetail with Invalid Params.
    */
   public function testGetGroupDetailInvalidParams() {
     $customGroupId = 99;
@@ -247,23 +232,22 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase {
   }
 
   /**
-   * Test getGroupDetail()
+   * Test getGroupDetail().
    */
   public function testGetGroupDetail() {
-    $customGrouptitle = 'My Custom Group';
+    $customGroupTitle = 'My Custom Group';
     $groupParams = array(
-      'title' => $customGrouptitle,
+      'title' => $customGroupTitle,
       'name' => 'My_Custom_Group',
       'extends' => 'Individual',
       'help_pre' => 'Custom Group Help Pre',
       'help_post' => 'Custom Group Help Post',
       'is_active' => 1,
       'collapse_display' => 1,
-      'version' => 3,
     );
 
-    $customGroup = Custom::createGroup($groupParams);
-    $customGroupId = $customGroup->id;
+    $customGroup = $this->customGroupCreate($groupParams);
+    $customGroupId = $customGroup['id'];
 
     $fieldParams = array(
       'custom_group_id' => $customGroupId,
@@ -273,14 +257,13 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase {
       'is_required' => 1,
       'is_searchable' => 0,
       'is_active' => 1,
-      'version' => 3,
     );
 
-    $customField = Custom::createField($fieldParams);
-    $customFieldId = $customField->id;
+    $customField = $this->customFieldCreate($fieldParams);
+    $customFieldId = $customField['id'];
 
     $groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail($customGroupId);
-    $dbCustomGroupTitle = $this->assertDBNotNull('CRM_Core_DAO_CustomGroup', $customGroupId, 'title', 'id',
+    $this->assertDBNotNull('CRM_Core_DAO_CustomGroup', $customGroupId, 'title', 'id',
       'Database check for custom group record.'
     );
     //check retieve values of custom group
@@ -295,9 +278,8 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase {
     unset($fieldParams['version']);
     $this->assertAttributesEquals($fieldParams, $groupTree[$customGroupId]['fields'][$customFieldId], " in line " . __LINE__);
 
-    //cleanup DB by deleting customGroup
-    Custom::deleteField($customField);
-    Custom::deleteGroup($customGroup);
+    $this->customFieldDelete($customField['id']);
+    $this->customGroupDelete($customGroup['id']);
   }
 
   /**
@@ -314,62 +296,50 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase {
    * Test getTitle()
    */
   public function testGetTitle() {
-    $customGrouptitle = 'My Custom Group';
+    $customGroupTitle = 'Custom Group';
     $groupParams = array(
-      'title' => $customGrouptitle,
+      'title' => $customGroupTitle,
       'name' => 'my_custom_group',
       'style' => 'Tab',
       'extends' => 'Individual',
       'is_active' => 0,
-      'version' => 3,
     );
 
-    $customGroup = Custom::createGroup($groupParams);
-    $customGroupId = $customGroup->id;
+    $customGroup = $this->customGroupCreate($groupParams);
+    $customGroupId = $customGroup['id'];
 
     //get the custom group title
     $title = CRM_Core_BAO_CustomGroup::getTitle($customGroupId);
 
     //check for object update
-    $this->assertEquals($customGrouptitle, $title);
+    $this->assertEquals($customGroupTitle, $title);
 
-    //cleanup DB by deleting customGroup
-    Custom::deleteGroup($customGroup);
+    $this->customGroupDelete($customGroupId);
   }
 
   /**
-   * Test deleteGroup()
+   * Test deleteGroup.
    */
   public function testDeleteGroup() {
-    $customGrouptitle = 'My Custom Group';
+    $customGroupTitle = 'My Custom Group';
     $groupParams = array(
-      'title' => $customGrouptitle,
+      'title' => $customGroupTitle,
       'name' => 'my_custom_group',
       'style' => 'Tab',
       'extends' => 'Individual',
       'is_active' => 1,
-      'version' => 3,
     );
 
-    $customGroup = Custom::createGroup($groupParams);
-
-    $customGroupId = $customGroup->id;
-
-    //get the custom group title
-    $dbCustomGroupTitle = $this->assertDBNotNull('CRM_Core_DAO_CustomGroup', $customGroupId, 'title', 'id',
-      'Database check for custom group record.'
-    );
-    //check for group title
-    $this->assertEquals($customGrouptitle, $dbCustomGroupTitle);
+    $customGroup = $this->customGroupCreate($groupParams);
+    $groupObject = new CRM_Core_BAO_CustomGroup();
+    $groupObject->id = $customGroup['id'];
+    $groupObject->find(TRUE);
 
-    //delete the group
-    $isDelete = CRM_Core_BAO_CustomGroup::deleteGroup($customGroup);
+    $isDelete = CRM_Core_BAO_CustomGroup::deleteGroup($groupObject);
 
-    //check for delete
+    // Check it worked!
     $this->assertEquals(TRUE, $isDelete);
-
-    //check the DB
-    $this->assertDBNull('CRM_Core_DAO_CustomGroup', $customGroupId, 'title', 'id',
+    $this->assertDBNull('CRM_Core_DAO_CustomGroup', $customGroup['id'], 'title', 'id',
       'Database check for custom group record.'
     );
   }
@@ -378,9 +348,8 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase {
    * Test createTable()
    */
   public function testCreateTable() {
-    $customGrouptitle = 'My Custom Group';
     $groupParams = array(
-      'title' => $customGrouptitle,
+      'title' => 'My Custom Group',
       'name' => 'my_custom_group',
       'style' => 'Tab',
       'extends' => 'Individual',
@@ -394,7 +363,7 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase {
     $tableName = 'civicrm_value_test_group_' . $customGroup->id;
     $customGroup->table_name = $tableName;
     $customGroup = $customGroupBAO->save();
-    $customTable = CRM_Core_BAO_CustomGroup::createTable($customGroup);
+    CRM_Core_BAO_CustomGroup::createTable($customGroup);
     $customGroupId = $customGroup->id;
 
     //check db for custom group.
@@ -406,32 +375,26 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase {
       $tableName, 'Database check for custom group table name.'
     );
 
-    //check for group title
-    $this->assertEquals($customGrouptitle, $dbCustomGroupTitle);
-
-    //cleanup DB by deleting customGroup
-    Custom::deleteGroup($customGroup);
+    $this->customGroupDelete($customGroup->id);
   }
 
   /**
    * Test checkCustomField()
    */
   public function testCheckCustomField() {
-    $customGroupTitle = 'My Custom Group';
     $groupParams = array(
-      'title' => $customGroupTitle,
+      'title' => 'My Custom Group',
       'name' => 'my_custom_group',
       'extends' => 'Individual',
       'help_pre' => 'Custom Group Help Pre',
       'help_post' => 'Custom Group Help Post',
       'is_active' => 1,
       'collapse_display' => 1,
-      'version' => 3,
     );
 
-    $customGroup = Custom::createGroup($groupParams);
-    $this->assertNotNull($customGroup->id, 'pre-requisite group not created successfully');
-    $customGroupId = $customGroup->id;
+    $customGroup = $this->customGroupCreate($groupParams);
+    $this->assertNotNull($customGroup['id'], 'pre-requisite group not created successfully');
+    $customGroupId = $customGroup['id'];
 
     $customFieldLabel = 'Test Custom Field';
     $fieldParams = array(
@@ -442,19 +405,12 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase {
       'is_required' => 1,
       'is_searchable' => 0,
       'is_active' => 1,
-      'version' => 3,
     );
 
-    $customField = Custom::createField($fieldParams);
-    $this->assertNotNull($customField->id, 'pre-requisite field not created successfully');
-
-    $customFieldId = $customField->id;
+    $customField = $this->customFieldCreate($fieldParams);
+    $customField = $customField['values'][$customField['id']];
 
-    //check db for custom group
-    $dbCustomGroupTitle = $this->assertDBNotNull('CRM_Core_DAO_CustomGroup', $customGroupId, 'title', 'id',
-      'Database check for custom group record.'
-    );
-    $this->assertEquals($customGroupTitle, $dbCustomGroupTitle);
+    $customFieldId = $customField['id'];
 
     //check db for custom field
     $dbCustomFieldLabel = $this->assertDBNotNull('CRM_Core_DAO_CustomField', $customFieldId, 'label', 'id',
@@ -471,9 +427,8 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase {
     $usedFor = CRM_Core_BAO_CustomGroup::checkCustomField($customFieldId, $params);
     $this->assertEquals(TRUE, $usedFor);
 
-    //cleanup DB by deleting customGroup
-    Custom::deleteField($customField);
-    Custom::deleteGroup($customGroup);
+    $this->customFieldDelete($customField['id']);
+    $this->customGroupDelete($customGroup['id']);
   }
 
   /**
@@ -487,29 +442,28 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase {
 
   public function testGetActiveGroups() {
     $contactId = $this->individualCreate();
-    $customGrouptitle = 'Test Custom Group';
+    $customGroupTitle = 'Custom Group';
     $groupParams = array(
-      'title' => $customGrouptitle,
+      'title' => $customGroupTitle,
       'name' => 'test_custom_group',
       'style' => 'Tab',
       'extends' => 'Individual',
       'weight' => 10,
       'is_active' => 1,
-      'version' => 3,
     );
 
-    $customGroup = Custom::createGroup($groupParams);
+    $customGroup = $this->customGroupCreate($groupParams);
     $activeGroup = CRM_Core_BAO_CustomGroup::getActiveGroups('Individual', 'civicrm/contact/view/cd', $contactId);
     foreach ($activeGroup as $key => $value) {
-      if ($value['id'] == $customGroup->id) {
+      if ($value['id'] == $customGroup['id']) {
         $this->assertEquals($value['path'], 'civicrm/contact/view/cd');
-        $this->assertEquals($value['title'], $customGrouptitle);
-        $query = 'reset=1&gid=' . $customGroup->id . '&cid=' . $contactId;
+        $this->assertEquals($value['title'], $customGroupTitle);
+        $query = 'reset=1&gid=' . $customGroup['id'] . '&cid=' . $contactId;
         $this->assertEquals($value['query'], $query);
       }
     }
 
-    Custom::deleteGroup($customGroup);
+    $this->customGroupDelete($customGroup['id']);
     $this->contactDelete($contactId);
   }
 
@@ -542,7 +496,7 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase {
     $this->assertEquals(strtolower("civicrm_value_{$params['name']}_{$customGroup->id}"), $dbCustomGroupTableName,
       "The table name should be suffixed with '_ID' unless specified.");
 
-    Custom::deleteGroup($customGroup);
+    $this->customGroupDelete($customGroup->id);
   }
 
   /**
@@ -560,7 +514,6 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase {
       'help_pre' => 'This is Pre Help For Test Group 1',
       'help_post' => 'This is Post Help For Test Group 1',
       'is_active' => 1,
-      'version' => 3,
     );
     $customGroup = CRM_Core_BAO_CustomGroup::create($params);
 
@@ -574,81 +527,74 @@ class CRM_Core_BAO_CustomGroupTest extends CiviUnitTestCase {
     );
     $this->assertEquals($params['table_name'], $dbCustomGroupTableName);
 
-    Custom::deleteGroup($customGroup);
+    $this->customGroupDelete($customGroup->id);
   }
 
   /**
    * Test isGroupEmpty()
    */
   public function testIsGroupEmpty() {
-    $customGrouptitle = 'Test Custom Group';
+    $customGroupTitle = 'Test Custom Group';
     $groupParams = array(
-      'title' => $customGrouptitle,
+      'title' => $customGroupTitle,
       'name' => 'test_custom_group',
       'style' => 'Tab',
       'extends' => 'Individual',
       'weight' => 10,
       'is_active' => 1,
-      'version' => 3,
     );
 
-    $customGroup = Custom::createGroup($groupParams);
-    $customGroupId = $customGroup->id;
+    $customGroup = $this->customGroupCreate($groupParams);
+    $customGroupId = $customGroup['id'];
     $isEmptyGroup = CRM_Core_BAO_CustomGroup::isGroupEmpty($customGroupId);
 
     $this->assertEquals($isEmptyGroup, TRUE, 'Check that custom Group is Empty.');
-    Custom::deleteGroup($customGroup);
+    $this->customGroupDelete($customGroup['id']);
   }
 
   /**
    * Test getGroupTitles() with Invalid Params()
    */
-  public function testgetGroupTitlesWithInvalidParams() {
+  public function testGetGroupTitlesWithInvalidParams() {
     $params = array(99);
     $groupTitles = CRM_Core_BAO_CustomGroup::getGroupTitles($params);
-    $this->assertTrue(empty($groupTitles), 'Check that no titles are recieved');
+    $this->assertTrue(empty($groupTitles), 'Check that no titles are received');
   }
 
   /**
    * Test getGroupTitles()
    */
-  public function testgetGroupTitles() {
-    $customGrouptitle = 'Test Custom Group';
+  public function testGetGroupTitles() {
     $groupParams = array(
-      'title' => $customGrouptitle,
+      'title' => 'Test Group',
       'name' => 'test_custom_group',
       'style' => 'Tab',
       'extends' => 'Individual',
       'weight' => 10,
       'is_active' => 1,
-      'version' => 3,
     );
 
-    $customGroup = Custom::createGroup($groupParams);
-
-    $customGroupId = $customGroup->id;
+    $customGroup = $this->customGroupCreate($groupParams);
 
-    $customFieldLabel = 'Test Custom Field';
     $fieldParams = array(
-      'custom_group_id' => $customGroupId,
-      'label' => $customFieldLabel,
+      'label' => 'Custom Field',
       'html_type' => 'Text',
       'data_type' => 'String',
       'is_required' => 1,
       'is_searchable' => 0,
       'is_active' => 1,
-      'version' => 3,
+      'custom_group_id' => $customGroup['id'],
     );
 
-    $customField = Custom::createField($fieldParams);
-    $customFieldId = $customField->id;
+    $customField = $this->customFieldCreate($fieldParams);
+    $customFieldId = $customField['id'];
 
     $params = array($customFieldId);
 
     $groupTitles = CRM_Core_BAO_CustomGroup::getGroupTitles($params);
 
-    $this->assertEquals($groupTitles[$customFieldId]['groupTitle'], 'Test Custom Group', 'Check Group Title.');
-    Custom::deleteGroup($customGroup);
+    $this->assertEquals($groupTitles[$customFieldId]['groupTitle'], 'Test Group', 'Check Group Title.');
+    $this->customGroupDelete($customGroup['id']);
   }
 
 }
index f00f5836beb2a4688036351c09bfc769fc8cbe9b..8d7255a5bd31c077755741a9eb265f34bc9faeaa 100644 (file)
@@ -11,139 +11,135 @@ class CRM_Core_BAO_CustomValueTableMultipleTest extends CiviUnitTestCase {
   }
 
   public function testCustomGroupMultipleSingle() {
-    $params = array();
     $contactID = $this->individualCreate();
-    $customGroup = Custom::createGroup($params, 'Individual', TRUE);
+    $customGroup = $this->customGroupCreate(array('is_multiple' => 1));
     $fields = array(
-      'groupId' => $customGroup->id,
+      'custom_group_id' => $customGroup['id'],
       'dataType' => 'String',
       'htmlType' => 'Text',
     );
-    $customField = Custom::createField($params, $fields);
+    $customField = $this->customFieldCreate($fields);
 
     $params = array(
       'entityID' => $contactID,
-      "custom_{$customField->id}_-1" => 'First String',
+      "custom_{$customField['id']}_-1" => 'First String',
     );
-    $error = CRM_Core_BAO_CustomValueTable::setValues($params);
+    CRM_Core_BAO_CustomValueTable::setValues($params);
 
     $newParams = array(
       'entityID' => $contactID,
-      "custom_{$customField->id}" => 1,
+      "custom_{$customField['id']}" => 1,
     );
     $result = CRM_Core_BAO_CustomValueTable::getValues($newParams);
 
-    $this->assertEquals($params["custom_{$customField->id}_-1"], $result["custom_{$customField->id}_1"]);
+    $this->assertEquals($params["custom_{$customField['id']}_-1"], $result["custom_{$customField['id']}_1"]);
     $this->assertEquals($params['entityID'], $result['entityID']);
 
-    Custom::deleteField($customField);
-    Custom::deleteGroup($customGroup);
+    $this->customFieldDelete($customField['id']);
+    $this->customGroupDelete($customGroup['id']);
     $this->contactDelete($contactID);
   }
 
   public function testCustomGroupMultipleDouble() {
-    $params = array();
     $contactID = $this->individualCreate();
-    $customGroup = Custom::createGroup($params, 'Individual', TRUE);
+    $customGroup = $this->customGroupCreate(array('is_multiple' => 1));
     $fields = array(
-      'groupId' => $customGroup->id,
+      'custom_group_id' => $customGroup['id'],
       'dataType' => 'String',
       'htmlType' => 'Text',
     );
-    $customField = Custom::createField($params, $fields);
+    $customField = $this->customFieldCreate($fields);
 
     $params = array(
       'entityID' => $contactID,
-      "custom_{$customField->id}_-1" => 'First String',
-      "custom_{$customField->id}_-2" => 'Second String',
+      "custom_{$customField['id']}_-1" => 'First String',
+      "custom_{$customField['id']}_-2" => 'Second String',
     );
-    $error = CRM_Core_BAO_CustomValueTable::setValues($params);
+    CRM_Core_BAO_CustomValueTable::setValues($params);
 
     $newParams = array(
       'entityID' => $contactID,
-      "custom_{$customField->id}" => 1,
+      "custom_{$customField['id']}" => 1,
     );
     $result = CRM_Core_BAO_CustomValueTable::getValues($newParams);
 
-    $this->assertEquals($params["custom_{$customField->id}_-1"], $result["custom_{$customField->id}_1"]);
-    $this->assertEquals($params["custom_{$customField->id}_-2"], $result["custom_{$customField->id}_2"]);
+    $this->assertEquals($params["custom_{$customField['id']}_-1"], $result["custom_{$customField['id']}_1"]);
+    $this->assertEquals($params["custom_{$customField['id']}_-2"], $result["custom_{$customField['id']}_2"]);
     $this->assertEquals($params['entityID'], $result['entityID']);
 
-    Custom::deleteField($customField);
-    Custom::deleteGroup($customGroup);
+    $this->customFieldDelete($customField['id']);
+    $this->customGroupDelete($customGroup['id']);
     $this->contactDelete($contactID);
   }
 
   public function testCustomGroupMultipleUpdate() {
-    $params = array();
     $contactID = $this->individualCreate();
-    $customGroup = Custom::createGroup($params, 'Individual', TRUE);
+    $customGroup = $this->customGroupCreate(array('is_multiple' => 1));
     $fields = array(
-      'groupId' => $customGroup->id,
+      'custom_group_id' => $customGroup['id'],
       'dataType' => 'String',
       'htmlType' => 'Text',
     );
-    $customField = Custom::createField($params, $fields);
+    $customField = $this->customFieldCreate($fields);
 
     $params = array(
       'entityID' => $contactID,
-      "custom_{$customField->id}_-1" => 'First String',
-      "custom_{$customField->id}_-2" => 'Second String',
-      "custom_{$customField->id}_-3" => 'Third String',
+      "custom_{$customField['id']}_-1" => 'First String',
+      "custom_{$customField['id']}_-2" => 'Second String',
+      "custom_{$customField['id']}_-3" => 'Third String',
     );
-    $error = CRM_Core_BAO_CustomValueTable::setValues($params);
+    CRM_Core_BAO_CustomValueTable::setValues($params);
 
     $newParams = array(
       'entityID' => $contactID,
-      "custom_{$customField->id}_1" => 'Updated First String',
-      "custom_{$customField->id}_3" => 'Updated Third String',
+      "custom_{$customField['id']}_1" => 'Updated First String',
+      "custom_{$customField['id']}_3" => 'Updated Third String',
     );
-    $result = CRM_Core_BAO_CustomValueTable::setValues($newParams);
+    CRM_Core_BAO_CustomValueTable::setValues($newParams);
 
     $getParams = array(
       'entityID' => $contactID,
-      "custom_{$customField->id}" => 1,
+      "custom_{$customField['id']}" => 1,
     );
     $result = CRM_Core_BAO_CustomValueTable::getValues($getParams);
 
-    $this->assertEquals($newParams["custom_{$customField->id}_1"], $result["custom_{$customField->id}_1"]);
-    $this->assertEquals($params["custom_{$customField->id}_-2"], $result["custom_{$customField->id}_2"]);
-    $this->assertEquals($newParams["custom_{$customField->id}_3"], $result["custom_{$customField->id}_3"]);
+    $this->assertEquals($newParams["custom_{$customField['id']}_1"], $result["custom_{$customField['id']}_1"]);
+    $this->assertEquals($params["custom_{$customField['id']}_-2"], $result["custom_{$customField['id']}_2"]);
+    $this->assertEquals($newParams["custom_{$customField['id']}_3"], $result["custom_{$customField['id']}_3"]);
     $this->assertEquals($params['entityID'], $result['entityID']);
 
-    Custom::deleteField($customField);
-    Custom::deleteGroup($customGroup);
+    $this->customFieldDelete($customField['id']);
+    $this->customGroupDelete($customGroup['id']);
     $this->contactDelete($contactID);
   }
 
-  public function testCustomGroupMultipleOldFormate() {
-    $params = array();
+  public function testCustomGroupMultipleOldFormat() {
     $contactID = $this->individualCreate();
-    $customGroup = Custom::createGroup($params, 'Individual', TRUE);
+    $customGroup = $this->customGroupCreate(array('is_multiple' => 1));
     $fields = array(
-      'groupId' => $customGroup->id,
+      'custom_group_id' => $customGroup['id'],
       'dataType' => 'String',
       'htmlType' => 'Text',
     );
-    $customField = Custom::createField($params, $fields);
+    $customField = $this->customFieldCreate($fields);
 
     $params = array(
       'entityID' => $contactID,
-      "custom_{$customField->id}" => 'First String',
+      "custom_{$customField['id']}" => 'First String',
     );
-    $error = CRM_Core_BAO_CustomValueTable::setValues($params);
+    CRM_Core_BAO_CustomValueTable::setValues($params);
 
     $newParams = array(
       'entityID' => $contactID,
-      "custom_{$customField->id}" => 1,
+      "custom_{$customField['id']}" => 1,
     );
     $result = CRM_Core_BAO_CustomValueTable::getValues($newParams);
 
-    $this->assertEquals($params["custom_{$customField->id}"], $result["custom_{$customField->id}_1"]);
+    $this->assertEquals($params["custom_{$customField['id']}"], $result["custom_{$customField['id']}_1"]);
     $this->assertEquals($params['entityID'], $result['entityID']);
 
-    Custom::deleteField($customField);
-    Custom::deleteGroup($customGroup);
+    $this->customFieldDelete($customField['id']);
+    $this->customGroupDelete($customGroup['id']);
     $this->contactDelete($contactID);
   }