Skip to content

Commit

Permalink
Fixed some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sudiptpa committed Nov 25, 2016
1 parent 48bb575 commit 0a5f683
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 58 deletions.
14 changes: 7 additions & 7 deletions tests/Message/DirectPostAuthorizeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ public function setUp()

$this->request->initialize(
array(
'merchantId' => 'foo',
'merchantId' => 'foo',
'transactionPassword' => 'bar',
'amount' => '12.00',
'returnUrl' => 'https://www.abc.com/return',
'card' => array(
'number' => '4444333322221111',
'amount' => '12.00',
'returnUrl' => 'https://www.abc.com/return',
'card' => array(
'number' => '4444333322221111',
'expiryMonth' => '6',
'expiryYear' => '2030',
'cvv' => '123',
'expiryYear' => '2030',
'cvv' => '123',
),
)
);
Expand Down
91 changes: 51 additions & 40 deletions tests/Message/DirectPostCompletePurchaseRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,74 +13,85 @@ public function setUp()

public function testGenerateResponseFingerprint()
{
$this->request->initialize(array(
'amount' => '465.18',
'transactionPassword' => 'abc123',
));
$this->request->initialize(
array(
'amount' => '465.18',
'transactionPassword' => 'abcd1234',
)
);

$data = array(
'timestamp' => '20130602102927',
'merchant' => 'ABC0030',
'refid' => '222',
'timestamp' => '20161125123332',
'merchant' => 'XYZ0010',
'refid' => '222',
'summarycode' => '2',
);

$this->assertSame('0516a31bf96ad89c354266afb9bd4be43aaf853f', $this->request->generateResponseFingerprint($data));
$this->assertSame('79200d1df5dc3f914a90ce476fdef317d224629f',
$this->request->generateResponseFingerprint($data));
}

public function testSuccess()
{
$this->request->initialize(array(
'amount' => '355.00',
'transactionPassword' => 'abc123',
));
$this->request->initialize(
array(
'amount' => '12.00',
'transactionPassword' => 'abcd1234',
'transactionId' => 'ORDER-ZYX8',
)
);

$this->getHttpRequest()->query->replace(array(
'timestamp' => '20130602112954',
'callback_status_code' => '',
'fingerprint' => 'd9b40fc6f841f41ef3475220fe6316406a5256ce',
'txnid' => '205861',
'merchant' => 'ABC0030',
'restext' => 'Approved',
'rescode' => '00',
'expirydate' => '032016',
'settdate' => '20130602',
'refid' => '226',
'pan' => '444433...111',
'summarycode' => '1',
));
$this->getHttpRequest()->query->replace(
array(
'timestamp' => '20161125130241',
'callback_status_code' => '-1',
'fingerprint' => 'e30eb8381bc41201fbdf54a021d8228a3fbb6a6f',
'txnid' => '271337',
'merchant' => 'XYZ0010',
'restext' => 'Approved',
'rescode' => '00',
'expirydate' => '20161126',
'settdate' => '20161126',
'refid' => 'ORDER-ZYX8',
'pan' => '444433...111',
'summarycode' => '1',
)
);

$response = $this->request->send();

$this->assertInstanceOf('Omnipay\NABTransact\Message\DirectPostCompletePurchaseResponse', $response);
$this->assertInstanceOf(
'Omnipay\NABTransact\Message\DirectPostCompletePurchaseResponse',
$response
);

$this->assertTrue($response->isSuccessful());
$this->assertFalse($response->isRedirect());
$this->assertSame('205861', $response->getTransactionReference());
$this->assertSame('271337', $response->getTransactionReference());
$this->assertSame('Approved', $response->getMessage());
$this->assertSame('00', $response->getCode());
}

public function testFailure()
{
$this->request->initialize(array(
'amount' => '465.18',
'amount' => '465.18',
'transactionPassword' => 'abc123',
));

$this->getHttpRequest()->query->replace(array(
'timestamp' => '20130602102927',
'timestamp' => '20130602102927',
'callback_status_code' => '',
'fingerprint' => '0516a31bf96ad89c354266afb9bd4be43aaf853f',
'txnid' => '205833',
'merchant' => 'ABC0030',
'restext' => 'Customer Dispute',
'rescode' => '18',
'expirydate' => '052016',
'settdate' => '20130602',
'refid' => '222',
'pan' => '444433...111',
'summarycode' => '2',
'fingerprint' => '0516a31bf96ad89c354266afb9bd4be43aaf853f',
'txnid' => '205833',
'merchant' => 'ABC0030',
'restext' => 'Customer Dispute',
'rescode' => '18',
'expirydate' => '052016',
'settdate' => '20130602',
'refid' => '222',
'pan' => '444433...111',
'summarycode' => '2',
));

$response = $this->request->send();
Expand Down
23 changes: 12 additions & 11 deletions tests/Message/DirectPostPurchaseRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ public function setUp()

$this->request->initialize(
array(
'merchantId' => 'foo',
'transactionPassword' => 'bar',
'amount' => '12.00',
'returnUrl' => 'https://www.example.com/return',
'card' => array(
'number' => '4444333322221111',
'expiryMonth' => '6',
'expiryYear' => '2020',
'cvv' => '123',
'merchantId' => 'XYZ0010',
'transactionPassword' => 'abcd1234',
'amount' => '12.00',
'returnUrl' => 'https://www.example.com/return',
'card' => array(
'number' => '4444333322221111',
'expiryMonth' => '06',
'expiryYear' => '2020',
'cvv' => '123',
),
)
);
Expand All @@ -29,9 +29,10 @@ public function setUp()
public function testFingerprint()
{
$data = $this->request->getData();
$data['EPS_TIMESTAMP'] = '20130416123332';
$data['EPS_TIMESTAMP'] = '20161125123332';

$this->assertSame('652856e75b04c5916a41082e04c9390961497f65', $this->request->generateFingerprint($data));
$this->assertSame('cbb64e71e360dba6337f22a00bdf0d0b89a7a568',
$this->request->generateFingerprint($data));
}

public function testSend()
Expand Down

0 comments on commit 0a5f683

Please sign in to comment.