From 8540c5260bf52216e3b66282ce0c5d9dd46f6fb0 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 11 May 2016 17:01:53 +1200 Subject: [PATCH] Improve test error reporting & sync test with master --- .../CRM/Core/Payment/AuthorizeNetTest.php | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php b/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php index 55759d15f5..1f323fbe41 100644 --- a/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php +++ b/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php @@ -176,7 +176,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->doDirectPayment($params); + $this->doPayment($params); // turn verifySSL on CRM_Core_BAO_Setting::setItem('0', CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL'); @@ -317,7 +317,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->doDirectPayment($params); + $this->doPayment($params); // turn verifySSL on CRM_Core_BAO_Setting::setItem('0', CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL'); @@ -333,4 +333,24 @@ 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 \CRM_Core_Exception + * @throws \PHPUnit_Framework_SkippedTestError + */ + public function doPayment($params) { + $result = $this->processor->doDirectPayment($params); + if (is_a($result, 'CRM_Core_Error')) { + if (strpos(CRM_Core_Error::getMessages($result), 'System error occurred') != FALSE) { + $this->markTestSkipped('AuthorizeNet test server is not in a good mood so we can\'t test this right now' . CRM_Core_Error::getMessages($result)); + } + throw new CRM_Core_Exception(CRM_Core_Error::getMessages($result)); + } + } + } -- 2.25.1