Fix CRM/Contact test to be E-Notice Compliant
authorEileen <eileen@fuzion.co.nz>
Fri, 3 Jan 2014 03:15:22 +0000 (16:15 +1300)
committerEileen <eileen@fuzion.co.nz>
Fri, 3 Jan 2014 03:15:22 +0000 (16:15 +1300)
tests/phpunit/CRM/Contact/BAO/ContactTest.php
tests/phpunit/CiviTest/Custom.php

index 2d13d1aae1ac7efad6cd297c2884c26766e3cedc..3398972bfff4663d396c2382d0f7daec0d499440 100644 (file)
@@ -3,7 +3,6 @@ require_once 'CiviTest/CiviUnitTestCase.php';
 require_once 'CiviTest/Contact.php';
 require_once 'CiviTest/Custom.php';
 class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase {
-  public $_eNoticeCompliant = FALSE;
   function get_info() {
     return array(
       'name' => 'Contact BAOs',
@@ -1522,26 +1521,23 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase {
     $customGroup = Custom::createGroup(array(), 'Individual');
     $this->assertNotNull($customGroup);
     $fields = array(
-      'groupId' => $customGroup->id,
+      'custom_group_id' => $customGroup->id,
       'data_type' => 'String',
       'html_type' => 'Text',
     );
-    $customField = Custom::createField(array(), $fields);
-    $this->assertNotNull($customField);
-
+    $customField = $this->customFieldCreate($fields);
+    $customField = $customField['values'][$customField['id']];
     $test = $this;
     $this->_testTimestamps(array(
       'INSERT' => function ($contactId) use ($test, $customGroup, $customField) {
-        $result = civicrm_api('contact', 'create', array(
-          'version' => 3,
+        $result = $this->callAPISuccess('contact', 'create', array(
           'contact_id' => $contactId,
-          'custom_' . $customField->id => 'test-1',
+          'custom_' . $customField['id'] => 'test-1',
         ));
-        $test->assertAPISuccess($result);
       },
       'UPDATE' => function ($contactId) use ($test, $customGroup, $customField) {
         CRM_Core_DAO::executeQuery(
-          "UPDATE {$customGroup->table_name} SET {$customField->column_name} = 'test-2' WHERE entity_id = %1",
+          "UPDATE {$customGroup->table_name} SET {$customField['column_name']} = 'test-2' WHERE entity_id = %1",
           array(1 => array($contactId, 'Integer'))
         );
       },
index 0beed103fa61af9111547386461162b432145bf9..cd5da954f2b81227cc5e68ae3bd1fcb2c5b926d6 100644 (file)
@@ -3,6 +3,7 @@ class Custom extends CiviUnitTestCase {
   /**
    * Helper function to create Custom Group
    *
+   * @deprecated - use functions on test case parent class
    * @return object of created group
    */
   static function createGroup($group, $extends = NULL, $isMultiple = FALSE) {
@@ -50,16 +51,16 @@ class Custom extends CiviUnitTestCase {
 
   /**
    * Helper function to create Custom Field
-   *
+   * @deprecated use parent object create fn
    * @return object of created field
    */
   static function createField($params, $fields = NULL) {
     if (empty($params)) {
       $params = array(
         'custom_group_id' => $fields['groupId'],
-        'label' => empty($fields['label']) ? 'test_' . $fields['dataType'] : $fields['label'],
-        'html_type' => $fields['htmlType'],
-        'data_type' => $fields['dataType'],
+        'label' => empty($fields['label']) ? 'test_' . CRM_Utils_Array::value('dataType', $fields) : $fields['label'],
+        'html_type' => CRM_Utils_Array::value('htmlType', $fields),
+        'data_type' => CRM_Utils_Array::value('dataType', $fields),
         'weight' => 4,
         'is_required' => 1,
         'is_searchable' => 0,
@@ -86,7 +87,7 @@ class Custom extends CiviUnitTestCase {
 
   /**
    * Helper function to delete custom field
-   *
+   * @deprecated use function on parent class
    * @param  object of Custom Field to delete
    */
   static function deleteField($params) {
@@ -96,7 +97,7 @@ class Custom extends CiviUnitTestCase {
 
   /**
    * Helper function to delete custom group
-   *
+   * @deprecated use function on parent class
    * @param  object Custom Group to delete
    * @return boolean true if Group deleted, false otherwise
    */