These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * eCoin driver for Omnipay PHP payment library |
||
5 | * |
||
6 | * @link https://github.com/hiqdev/omnipay-ecoin |
||
7 | * @package omnipay-ecoin |
||
8 | * @license MIT |
||
9 | * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) |
||
10 | */ |
||
11 | |||
12 | namespace Omnipay\eCoin\Message; |
||
13 | |||
14 | use Omnipay\Tests\TestCase; |
||
15 | |||
16 | class CompletePurchaseResponseTest extends TestCase |
||
17 | { |
||
18 | private $request; |
||
19 | |||
20 | private $purse = 'ec12345'; |
||
21 | private $secret = '22SAD#-78G8sdf$88'; |
||
22 | private $hash = 'fbbc3a665048e3f4aa001dd212b82588'; |
||
23 | private $description = 'Test Transaction long description'; |
||
24 | private $transactionId = '1SD672345A890sd'; |
||
25 | private $transactionReference = 'sdfa1SD672345A8'; |
||
26 | private $timestamp = '1454331086'; |
||
27 | private $payer = 'ec54321'; |
||
28 | private $amount = '1465.01'; |
||
29 | private $status = 'done'; |
||
0 ignored issues
–
show
Comprehensibility
introduced
by
Loading history...
|
|||
30 | private $currency = 'USD'; |
||
31 | private $testMode = false; |
||
32 | |||
33 | public function setUp() |
||
34 | { |
||
35 | parent::setUp(); |
||
36 | |||
37 | $this->request = new CompletePurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); |
||
38 | $this->request->initialize([ |
||
39 | 'purse' => $this->purse, |
||
40 | 'secret' => $this->secret, |
||
41 | 'testMode' => $this->testMode, |
||
42 | ]); |
||
43 | } |
||
44 | |||
45 | public function testInvalidHashException() |
||
46 | { |
||
47 | $this->setExpectedException('Omnipay\Common\Exception\InvalidResponseException', 'Invalid hash'); |
||
48 | new CompletePurchaseResponse($this->request, [ |
||
49 | 'description' => $this->description, |
||
50 | ]); |
||
51 | } |
||
52 | |||
53 | public function testSuccess() |
||
54 | { |
||
55 | $response = new CompletePurchaseResponse($this->request, [ |
||
56 | 'ECM_HASH' => $this->hash, |
||
57 | 'ECM_PURCH_DESC' => $this->description, |
||
58 | 'ECM_PAYER_ID' => $this->payer, |
||
59 | 'ECM_PAYEE_ID' => $this->purse, |
||
60 | 'ECM_PAYMENT_AMOUNT' => $this->amount, |
||
61 | 'ECM_ITEM_COST' => $this->amount, |
||
62 | 'ECM_TRANS_DATE' => $this->timestamp, |
||
63 | 'ECM_INV_NO' => $this->transactionId, |
||
64 | 'ECM_TRANS_ID' => $this->transactionReference, |
||
65 | ]); |
||
66 | |||
67 | $this->assertTrue($response->isSuccessful()); |
||
68 | $this->assertFalse($response->getTestMode()); |
||
69 | $this->assertNull($response->getMessage()); |
||
70 | $this->assertNull($response->getCode()); |
||
71 | $this->assertSame($this->transactionId, $response->getTransactionId()); |
||
72 | $this->assertSame($this->transactionReference, $response->getTransactionReference()); |
||
73 | $this->assertSame($this->amount, $response->getAmount()); |
||
74 | $this->assertSame($this->payer, $response->getPayer()); |
||
75 | $this->assertSame($this->hash, $response->getHash()); |
||
76 | $this->assertSame($this->currency, $response->getCurrency()); |
||
77 | $this->assertSame('2016-02-01T12:51:26+00:00', $response->getTime()); |
||
78 | } |
||
79 | } |
||
80 |