From fbd1b89e7722097c1119533599e3e70c624b9902 Mon Sep 17 00:00:00 2001 From: Eileen Date: Fri, 3 Jan 2014 16:15:22 +1300 Subject: [PATCH] Fix CRM/Contact test to be E-Notice Compliant --- tests/phpunit/CRM/Contact/BAO/ContactTest.php | 16 ++++++---------- tests/phpunit/CiviTest/Custom.php | 13 +++++++------ 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/tests/phpunit/CRM/Contact/BAO/ContactTest.php b/tests/phpunit/CRM/Contact/BAO/ContactTest.php index 2d13d1aae1..3398972bff 100644 --- a/tests/phpunit/CRM/Contact/BAO/ContactTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ContactTest.php @@ -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')) ); }, diff --git a/tests/phpunit/CiviTest/Custom.php b/tests/phpunit/CiviTest/Custom.php index 0beed103fa..cd5da954f2 100644 --- a/tests/phpunit/CiviTest/Custom.php +++ b/tests/phpunit/CiviTest/Custom.php @@ -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 */ -- 2.25.1