Skip to content

Commit 2036ac4

Browse files
committed
Added more tests
1 parent 04e30ef commit 2036ac4

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
namespace Omnipay\NABTransact\Message;
4+
5+
use Omnipay\Tests\TestCase;
6+
7+
class DirectPostPurchaseRequestTest extends TestCase
8+
{
9+
public function setUp()
10+
{
11+
$this->request = new DirectPostPurchaseRequest($this->getHttpClient(), $this->getHttpRequest());
12+
13+
$this->request->initialize(
14+
array(
15+
'merchantId' => 'foo',
16+
'transactionPassword' => 'bar',
17+
'amount' => '12.00',
18+
'returnUrl' => 'https://www.example.com/return',
19+
'card' => array(
20+
'number' => '4444333322221111',
21+
'expiryMonth' => '6',
22+
'expiryYear' => '2020',
23+
'cvv' => '123',
24+
),
25+
)
26+
);
27+
}
28+
29+
public function testFingerprint()
30+
{
31+
$data = $this->request->getData();
32+
$data['EPS_TIMESTAMP'] = '20130416123332';
33+
34+
$this->assertSame('652856e75b04c5916a41082e04c9390961497f65', $this->request->generateFingerprint($data));
35+
}
36+
37+
public function testSend()
38+
{
39+
$response = $this->request->send();
40+
41+
$this->assertInstanceOf('Omnipay\NABTransact\Message\DirectPostAuthorizeResponse', $response);
42+
$this->assertFalse($response->isSuccessful());
43+
$this->assertTrue($response->isRedirect());
44+
$this->assertNull($response->getTransactionReference());
45+
$this->assertNull($response->getMessage());
46+
$this->assertNull($response->getCode());
47+
48+
$this->assertSame('https://transact.nab.com.au/live/directpostv2/authorise', $response->getRedirectUrl());
49+
$this->assertSame('POST', $response->getRedirectMethod());
50+
51+
$data = $response->getData();
52+
$this->assertArrayHasKey('EPS_FINGERPRINT', $data);
53+
$this->assertSame('0', $data['EPS_TXNTYPE']);
54+
}
55+
}

0 commit comments

Comments
 (0)