From: Coleman Watts Date: Fri, 31 May 2013 18:02:12 +0000 (-0700) Subject: Fix tests and api options validation CRM-12464 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ace01fda1eac9779dbb1530cd168d7eb51cb0c12;p=civicrm-core.git Fix tests and api options validation CRM-12464 ---------------------------------------- * CRM-12464: Add PseudoConstants to Schema Metadata http://issues.civicrm.org/jira/browse/CRM-12464 --- diff --git a/api/v3/utils.php b/api/v3/utils.php index 0934f7c2f2..da71cdfbb2 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -1445,7 +1445,7 @@ function _civicrm_api3_validate_integer(&$params, &$fieldname, &$fieldInfo, $ent $session = &CRM_Core_Session::singleton(); $params[$fieldname] = $session->get('userID'); } - if (CRM_Utils_Array::value('pseudoconstant', $fieldInfo) ) { + if (!empty($fieldInfo['options'])) { $constant = CRM_Utils_Array::value('options', $fieldInfo); if (is_numeric($params[$fieldname]) && !CRM_Utils_Array::value('FKClassName',$fieldInfo) && !array_key_exists($params[$fieldname], $fieldInfo['options'])) { throw new API_Exception("$fieldname is not valid", 2001, array('error_field' => $fieldname,"type"=>"integer")); diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 021c725ae1..22fee9a65d 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -675,19 +675,23 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { */ private function _contactCreate($params) { $params['version'] = API_LATEST_VERSION; - $result = civicrm_api('Contact', 'create', $params); + $params['debug'] = 1; + $result = civicrm_api('contact', 'create', $params); if (CRM_Utils_Array::value('is_error', $result) || !CRM_Utils_Array::value('id', $result) ) { - throw new Exception('Could not create test contact, with message: ' . CRM_Utils_Array::value('error_message', $result)); + throw new Exception('Could not create test contact, with message: ' . CRM_Utils_Array::value('error_message', $result) . "\nBacktrace:" . CRM_Utils_Array::value('trace', $result)); } return $result['id']; } function contactDelete($contactID) { - $params['id'] = $contactID; - $params['version'] = API_LATEST_VERSION; - $params['skip_undelete'] = 1; + $params = array( + 'id' => $contactID, + 'version' => API_LATEST_VERSION, + 'skip_undelete' => 1, + 'debug' => 1, + ); $domain = new CRM_Core_BAO_Domain; $domain->contact_id = $contactID; if ($domain->find(TRUE)) { @@ -695,9 +699,9 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { //since this is mainly for cleanup lets put a safeguard here return; } - $result = civicrm_api('Contact', 'delete', $params); + $result = civicrm_api('contact', 'delete', $params); if (CRM_Utils_Array::value('is_error', $result)) { - throw new Exception('Could not delete contact, with message: ' . CRM_Utils_Array::value('error_message', $result)); + throw new Exception('Could not delete contact, with message: ' . CRM_Utils_Array::value('error_message', $result) . "\nBacktrace:" . CRM_Utils_Array::value('trace', $result)); } return; }