From 7f5c21bb5e5ebc122cb3646f378427c120a3e2ac Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 7 Dec 2015 14:01:39 +1300 Subject: [PATCH] Add some tolerance to Authorize.net test Change-Id: I0c00bd47294fb4be06d017b56e80dca7c87f4eea --- .../CRM/Core/Payment/AuthorizeNetTest.php | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php b/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php index f1038f82ba..c766c40499 100644 --- a/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php +++ b/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php @@ -166,7 +166,7 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase { // turn verifySSL off CRM_Core_BAO_Setting::setItem('0', CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL'); - $this->processor->doPayment($params); + $this->doPayment($params); // turn verifySSL on CRM_Core_BAO_Setting::setItem('0', CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL'); @@ -307,7 +307,7 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase { // turn verifySSL off CRM_Core_BAO_Setting::setItem('0', CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL'); - $result = $this->processor->doPayment($params); + $this->doPayment($params); // turn verifySSL on CRM_Core_BAO_Setting::setItem('0', CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL'); @@ -323,4 +323,23 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase { $this->assertTrue($result, 'Failed to cancel subscription with Authorize.'); } + /** + * Process payment against the Authorize.net test server. + * + * Skip the test if the server is unresponsive. + * + * @param array $params + * + * @throws PHPUnit_Framework_SkippedTestError + */ + public function doPayment($params) { + try { + $this->processor->doPayment($params); + } + catch (Exception $e) { + $this->assertEquals('E00001: Internal Error Occurred.', $e->getMessage(), 'AuthorizeNet failed for unknown reason.'); + $this->markTestSkipped('AuthorizeNet test server is not in a good mood so we can\'t test this right now'); + } + } + } -- 2.25.1