From 64fe97dab89d13b18dfcc96e39255adb6ddab1cc Mon Sep 17 00:00:00 2001 From: eileen Date: Sun, 30 Jun 2013 17:10:14 +1200 Subject: [PATCH] enhance api failure function --- tests/phpunit/CiviTest/CiviUnitTestCase.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 6bf34bacf5..dd253a6410 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -617,10 +617,13 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { * @param array $apiResult api result * @param string $prefix extra test to add to message */ - function assertAPIFailure($apiResult, $prefix = '') { + function assertAPIFailure($apiResult, $prefix = '', $expectedError = NULL) { if (!empty($prefix)) { $prefix .= ': '; } + if($expectedError && !empty($apiResult['is_error'])){ + $this->assertEquals($expectedError, $apiResult['error_message'], 'api error message not as expected' . $prefix ); + } $this->assertEquals(1, $apiResult['is_error'], "api call should have failed but it succeeded " . $prefix . (print_r($apiResult, TRUE))); } @@ -708,8 +711,9 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { * @param string $entity * @param string $action * @param array $params + * @param string $expectedErrorMessage error */ - function callAPIFailure($entity, $action, $params) { + function callAPIFailure($entity, $action, $params, $expectedErrorMessage = NULL, $extraOutput = NULL) { if (is_array($params)) { $params += array( 'version' => API_LATEST_VERSION, -- 2.25.1