From 507d3b64f7cef574d8a8fe13fc9a258c6c1d2d42 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 12 Jan 2015 16:47:51 +1300 Subject: [PATCH] minor function tidy-ups --- Civi/Payment/System.php | 4 +-- tests/phpunit/CiviTest/CiviUnitTestCase.php | 35 +++++++++------------ 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/Civi/Payment/System.php b/Civi/Payment/System.php index 9b1b9d491f..99ed9104ae 100644 --- a/Civi/Payment/System.php +++ b/Civi/Payment/System.php @@ -30,7 +30,7 @@ class System { /** * @param array $processor - * @throws \Civi\Payment\CRM_Core_Exception + * @throws \CRM_Core_Exception */ public function getByProcessor($processor) { $id = $processor['id']; @@ -47,7 +47,7 @@ class System { else { $paymentClass = 'CRM_Core_' . $processor['class_name']; if (empty($paymentClass)) { - throw new CRM_Core_Exception('no class provided'); + throw new \CRM_Core_Exception('no class provided'); } require_once str_replace('_', DIRECTORY_SEPARATOR, $paymentClass) . '.php'; } diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index cde898f8a9..596bf3b53f 100755 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -1190,25 +1190,20 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { } /** - * @param int $contactID + * Delete contact, ensuring it is not the domain contact * - * @return array|int + * @param int $contactID + * Contact ID to delete */ public function contactDelete($contactID) { - $params = array( - 'id' => $contactID, - 'skip_undelete' => 1, - 'debug' => 1, - ); $domain = new CRM_Core_BAO_Domain; $domain->contact_id = $contactID; - if ($domain->find(TRUE)) { - // we are finding tests trying to delete the domain contact in cleanup - //since this is mainly for cleanup lets put a safeguard here - return; + if (!$domain->find(TRUE)) { + $this->callAPISuccess('contact', 'delete', array( + 'id' => $contactID, + 'skip_undelete' => 1, + )); } - $result = $this->callAPISuccess('contact', 'delete', $params); - return $result; } /** @@ -2157,7 +2152,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { * * @param array $params * (custom_group_id) is required. - * @return array|int + * @return array */ public function customFieldCreate($params) { $params = array_merge(array( @@ -2170,13 +2165,10 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { ), $params); $result = $this->callAPISuccess('custom_field', 'create', $params); - - if ($result['is_error'] == 0 && isset($result['id'])) { - CRM_Core_BAO_CustomField::getTableColumnGroup($result['id'], 1); - // force reset of enabled components to help grab custom fields - CRM_Core_Component::getEnabledComponents(1); - return $result; - } + // these 2 functions are called with force to flush static caches + CRM_Core_BAO_CustomField::getTableColumnGroup($result['id'], 1); + CRM_Core_Component::getEnabledComponents(1); + return $result; } /** @@ -2494,6 +2486,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { /** * @param $tablesToTruncate * @param bool $dropCustomValueTables + * @throws \Exception */ public function quickCleanup($tablesToTruncate, $dropCustomValueTables = FALSE) { if ($this->tx) { -- 2.25.1