|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Omnipay\Eway\Message; |
| 4 | + |
| 5 | +use Omnipay\Tests\TestCase; |
| 6 | + |
| 7 | +class RapidDirectVoidRequestTest extends TestCase |
| 8 | +{ |
| 9 | + public function setUp() |
| 10 | + { |
| 11 | + $this->request = new RapidDirectVoidRequest($this->getHttpClient(), $this->getHttpRequest()); |
| 12 | + $this->request->initialize(array( |
| 13 | + 'apiKey' => 'my api key', |
| 14 | + 'password' => 'secret', |
| 15 | + 'transactionReference' => '4324324' |
| 16 | + )); |
| 17 | + } |
| 18 | + |
| 19 | + public function testGetData() |
| 20 | + { |
| 21 | + $this->request->initialize(array( |
| 22 | + 'apiKey' => 'my api key', |
| 23 | + 'password' => 'secret', |
| 24 | + 'transactionReference' => '4324324' |
| 25 | + )); |
| 26 | + |
| 27 | + $data = $this->request->getData(); |
| 28 | + |
| 29 | + $this->assertSame('4324324', $data['TransactionId']); |
| 30 | + } |
| 31 | + |
| 32 | + public function testSendSuccess() |
| 33 | + { |
| 34 | + $this->setMockHttpResponse('RapidDirectVoidRequestSuccess.txt'); |
| 35 | + $response = $this->request->send(); |
| 36 | + |
| 37 | + $this->assertTrue($response->isSuccessful()); |
| 38 | + $this->assertFalse($response->isRedirect()); |
| 39 | + $this->assertSame('12921019', $response->getTransactionReference()); |
| 40 | + $this->assertSame('Transaction Approved', $response->getMessage()); |
| 41 | + } |
| 42 | + |
| 43 | + public function testSendFailure() |
| 44 | + { |
| 45 | + $this->setMockHttpResponse('RapidDirectVoidRequestFailure.txt'); |
| 46 | + $response = $this->request->send(); |
| 47 | + |
| 48 | + $this->assertFalse($response->isSuccessful()); |
| 49 | + $this->assertFalse($response->isRedirect()); |
| 50 | + $this->assertSame('0', $response->getTransactionReference()); |
| 51 | + $this->assertSame('Invalid Auth Transaction ID for Capture/Void', $response->getMessage()); |
| 52 | + $this->assertSame('V6134', $response->getCode()); |
| 53 | + } |
| 54 | +} |
0 commit comments