From: eileen Date: Mon, 10 Aug 2020 05:38:30 +0000 (+1200) Subject: [Ref] [Test] Update Authorize.net test to use the trait X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=926996952ed16669e9a1abe43ba813e9a84df833;p=civicrm-core.git [Ref] [Test] Update Authorize.net test to use the trait --- diff --git a/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php b/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php index 3ef5c7ef9b..0959ad2af1 100644 --- a/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php +++ b/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php @@ -17,12 +17,7 @@ use Civi\Payment\PropertyBag; */ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase { - use \Civi\Test\GuzzleTestTrait; - - /** - * @var \CRM_Core_Payment_AuthorizeNet - */ - protected $processor; + use CRM_Core_Payment_AuthorizeNetTrait; public function setUp() { parent::setUp(); @@ -44,44 +39,24 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase { * Test doing a one-off payment. * * @throws \Civi\Payment\Exception\PaymentProcessorException + * @throws \CiviCRM_API3_Exception */ public function testSinglePayment() { - $this->createMockHandler([$this->getExpectedSinglePaymentResponse()]); - $this->setUpClientWithHistoryContainer(); - $this->processor->setGuzzleClient($this->getGuzzleClient()); + $this->setupMockHandler(); $params = $this->getBillingParams(); $params['amount'] = 5.24; $this->processor->doPayment($params); $this->assertEquals($this->getExpectedSinglePaymentRequest(), $this->getRequestBodies()[0]); } - /** - * Get the expected response from Authorize.net. - * - * @return string - */ - public function getExpectedSinglePaymentResponse() { - return '"1","1","1","(TESTMODE) This transaction has been approved.","000000","P","0","","","5.24","CC","auth_capture","","John","O'Connor","","","","","","","","","","","","","","","","","","","","","","","",""'; - } - - /** - * Get the expected request from Authorize.net. - * - * @return string - */ - public function getExpectedSinglePaymentRequest() { - return 'x_login=4y5BfuW7jm&x_tran_key=4cAmW927n8uLf5J8&x_email_customer=&x_first_name=John&x_last_name=O%27Connor&x_address=&x_city=&x_state=&x_zip=&x_country=&x_customer_ip=&x_email=&x_invoice_num=&x_amount=5.24&x_currency_code=&x_description=&x_cust_id=&x_relay_response=FALSE&x_delim_data=TRUE&x_delim_char=%2C&x_encap_char=%22&x_card_num=4444333322221111&x_card_code=123&x_exp_date=10%2F2022&x_test_request=TRUE'; - } - /** * Create a single post dated payment as a recurring transaction. * * Test works but not both due to some form of caching going on in the SmartySingleton */ public function testCreateSingleNowDated() { - $this->createMockHandler([$this->getExpectedResponse()]); - $this->setUpClientWithHistoryContainer(); - $this->processor->setGuzzleClient($this->getGuzzleClient()); + $this->isRecur = TRUE; + $this->setupMockHandler(); $firstName = 'John'; $lastName = "O\'Connor"; $nameParams = ['first_name' => 'John', 'last_name' => $lastName]; @@ -203,9 +178,8 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase { * Create a single post dated payment as a recurring transaction. */ public function testCreateSinglePostDated() { - $this->createMockHandler([$this->getExpectedResponse()]); - $this->setUpClientWithHistoryContainer(); - $this->processor->setGuzzleClient($this->getGuzzleClient()); + $this->isRecur = TRUE; + $this->setupMockHandler(); $start_date = date('Ymd', strtotime('+ 1 week')); $firstName = 'John'; @@ -329,7 +303,7 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase { ); $response = $this->getResponseBodies(); - $this->assertEquals($this->getExpectedResponse(), $response[0], 3); + $this->assertEquals($this->getExpectedRecurResponse(), $response[0], 3); $requests = $this->getRequestBodies(); $this->assertEquals($this->getExpectedRequest($contactId, date('Y-m-d', strtotime($start_date)), 70.23, 3, 4007000000027, '2022-10'), $requests[0]); } @@ -392,15 +366,6 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase { '; } - /** - * Get a successful response to setting up a recurring. - * - * @return string - */ - public function getExpectedResponse() { - return '8d468ca1b1dd5c2b56c7OkI00001Successful.663205215120232801512027350'; - } - /** * Get some basic billing parameters. * diff --git a/tests/phpunit/CRM/Mailing/Form/Task/AdhocMailingTest.php b/tests/phpunit/CRM/Mailing/Form/Task/AdhocMailingTest.php index 2f427ee905..c579c87d26 100644 --- a/tests/phpunit/CRM/Mailing/Form/Task/AdhocMailingTest.php +++ b/tests/phpunit/CRM/Mailing/Form/Task/AdhocMailingTest.php @@ -40,7 +40,6 @@ class CRM_Mailing_Form_Task_AdhocMailingTest extends CiviUnitTestCase { public function testCreateHiddenGroupFromSearchBuilder() { $this->createLoggedInUser(); $formValues = [ - 'qfKey' => 'dde96a85ddebb90fb66de44859404aeb_2077', 'entryURL' => 'http://dmaster.local/civicrm/contact/search/builder?reset=1', 'mapper' => [1 => [['Individual']]], 'operator' => [1 => ['=']],