From 5c496c74b58c9cfeab796a18ace9226f7001e607 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 20 Aug 2013 16:51:55 +1200 Subject: [PATCH] CRM-13234 minor enhancements to test parent class to better support ufField, function documenting --- tests/phpunit/CiviTest/CiviUnitTestCase.php | 38 +++++++++++++++------ 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 585bef122e..9206023975 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -1492,6 +1492,24 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { $this->callAPISuccess('Group', 'delete', $params); } + /** + * Create a UFField + * @param array $params + */ + function uFFieldCreate($params = array()) { + $params = array_merge(array( + 'uf_group_id' => 1, + 'field_name' => 'first_name', + 'is_active' => 1, + 'is_required' => 1, + 'visibility' => 'Public Pages and Listings', + 'is_searchable' => '1', + 'label' => 'first_name', + 'field_type' => 'Individual', + 'weight' => 1, + ), $params); + $this->callAPISuccess('uf_field', 'create', $params); + } /** * Function to add a UF Join Entry * @@ -1748,10 +1766,10 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { 'html_type' => 'Text', 'is_searchable' => 1, 'is_active' => 1, - 'version' => $this->_apiversion, + 'default_value' => 'defaultValue', ); - $result = civicrm_api('custom_field', 'create', $params); + $result = $this->callAPISuccess('custom_field', 'create', $params); if ($result['is_error'] == 0 && isset($result['id'])) { CRM_Core_BAO_CustomField::getTableColumnGroup($result['id'], 1); @@ -1759,12 +1777,6 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { CRM_Core_Component::getEnabledComponents(1); return $result; } - - if (civicrm_error($result) - || !(CRM_Utils_Array::value('customFieldId', $result['result'])) - ) { - throw new Exception('Could not create Custom Field ' . $result['error_message']); - } } /** @@ -1834,6 +1846,10 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { $action = empty($action) ? 'getcount' : $action; $entityAction = 'GetCount'; } + elseif (strstr($function, 'GetFields')) { + $action = empty($action) ? 'getfields' : $action; + $entityAction = 'GetFields'; + } elseif (strstr($function, 'Get')) { $action = empty($action) ? 'get' : $action; $entityAction = 'Get'; @@ -1850,9 +1866,9 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { $action = empty($action) ? 'subscribe' : $action; $entityAction = 'Subscribe'; } - elseif (strstr($function, 'Set')) { - $action = empty($action) ? 'set' : $action; - $entityAction = 'Set'; + elseif (strstr($function, 'Submit')) { + $action = empty($action) ? 'submit' : $action; + $entityAction = 'Submit'; } elseif (strstr($function, 'Apply')) { $action = empty($action) ? 'apply' : $action; -- 2.25.1