Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
BackendResponseTest.php
Go to the documentation of this file.
1 <?php
8 
10 
12 {
16  private static $entryPoint = 'authorizenet/directpost_payment/backendresponse';
17 
21  public function testUnauthorizedRequest()
22  {
23  $data = [
24  'x_response_code' => 1,
25  'x_response_reason_code' => 1,
26  'x_invoice_num' => 1,
27  'x_amount' => 16,
28  'x_trans_id' => '32iiw5ve',
29  'x_card_type' => 'American Express',
30  'x_account_number' => 'XXXX0002',
31  'x_MD5_Hash' => 'h6a4s2h'
32  ];
33  $this->getRequest()->setPostValue($data);
34  $this->dispatch(self::$entryPoint);
35 
36  self::assertEquals(302, $this->getResponse()->getHttpResponseCode());
37  self::assertEmpty($this->getResponse()->getBody());
38  }
39 
46  public function testSuccess()
47  {
48  $data = [
49  'x_response_code' => 1,
50  'x_response_reason_code' => 1,
51  'x_invoice_num' => 1,
52  'x_amount' => 16,
53  'x_trans_id' => '32iiw5ve',
54  'x_card_type' => 'American Express',
55  'x_account_number' => 'XXXX0002',
56  'x_MD5_Hash' => '0EAD2F65D3D879CCB0D1A6F24883AC92'
57  ];
58  $this->getRequest()->setPostValue($data);
59  $this->dispatch(self::$entryPoint);
60  self::assertEquals(200, $this->getResponse()->getHttpResponseCode());
61  self::assertContains('/sales/order/view', $this->getResponse()->getBody());
62  }
63 }
dispatch(RequestInterface $request)
Definition: Action.php:92