|
1 | 1 | <?php
|
2 | 2 |
|
3 |
| -namespace Omnipay\IcepayPayments; |
| 3 | +namespace Omnipay\IcepayPayments\Tests; |
4 | 4 |
|
5 | 5 | use Omnipay\Common\GatewayInterface;
|
6 |
| -use PHPUnit\Framework\TestCase; |
| 6 | +use Omnipay\IcepayPayments\Gateway; |
| 7 | +use Omnipay\IcepayPayments\Message\CreateTransactionRequest; |
| 8 | +use Omnipay\IcepayPayments\Message\RefundRequest; |
| 9 | +use Omnipay\IcepayPayments\Message\TransactionStatusRequest; |
7 | 10 |
|
8 | 11 | /**
|
9 | 12 | * Tests the Icepay gateway.
|
10 | 13 | */
|
11 |
| -class GatewayTest extends TestCase |
| 14 | +class GatewayTest extends AbstractTestCase |
12 | 15 | {
|
13 | 16 | /**
|
14 | 17 | * @var GatewayInterface
|
15 | 18 | */
|
16 | 19 | public $gateway;
|
17 | 20 |
|
| 21 | + /** |
| 22 | + * @var array |
| 23 | + */ |
| 24 | + private $options; |
| 25 | + |
18 | 26 | /**
|
19 | 27 | * Creates a new Gateway instance for testing.
|
20 | 28 | */
|
21 | 29 | protected function setUp(): void
|
22 | 30 | {
|
23 |
| - $this->gateway = new Gateway(); |
| 31 | + $this->gateway = new Gateway($this->httpClient, $this->httpRequest); |
| 32 | + $this->options = [ |
| 33 | + 'paymentMethod' => 'IDEAL', |
| 34 | + 'amountInCents' => 1337, |
| 35 | + 'currencyCode' => 'EUR', |
| 36 | + 'languageCode' => 'nl', |
| 37 | + 'countryCode' => 'NL', |
| 38 | + 'issuerCode' => 'ABNAMRO', |
| 39 | + 'reference' => '829c7998-6497-402c-a049-51801ba33662', |
| 40 | + ]; |
24 | 41 | }
|
25 | 42 |
|
26 | 43 | /**
|
@@ -50,13 +67,54 @@ public function testFetchTransactionParameters(): void
|
50 | 67 | $setter = 'set'.ucfirst($this->camelCase($key));
|
51 | 68 | $value = uniqid();
|
52 | 69 | $this->gateway->$setter($value);
|
| 70 | + $this->assertSame($value, $this->gateway->$getter()); |
53 | 71 |
|
54 | 72 | // request should have matching property, with correct value
|
55 | 73 | $request = $this->gateway->fetchTransaction();
|
56 |
| - $this->assertSame($value, $request->$getter()); |
| 74 | + $this->assertSame($this->gateway->$getter(), $request->$getter()); |
57 | 75 | }
|
58 | 76 | }
|
59 | 77 |
|
| 78 | + /** |
| 79 | + * Tests if Gateway::authorize will return an instance of CreateTransactionRequest. |
| 80 | + */ |
| 81 | + public function testAuthorize(): void |
| 82 | + { |
| 83 | + $request = $this->gateway->authorize($this->options); |
| 84 | + |
| 85 | + $this->assertInstanceOf(CreateTransactionRequest::class, $request); |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + * Tests if Gateway::completeAuthorize will return an instance of TransactionStatusRequest. |
| 90 | + */ |
| 91 | + public function testCompleteAuthorize(): void |
| 92 | + { |
| 93 | + $request = $this->gateway->completeAuthorize($this->options); |
| 94 | + |
| 95 | + $this->assertInstanceOf(TransactionStatusRequest::class, $request); |
| 96 | + } |
| 97 | + |
| 98 | + /** |
| 99 | + * Tests if Gateway::capture will return an instance of TransactionStatusRequest. |
| 100 | + */ |
| 101 | + public function testCapture(): void |
| 102 | + { |
| 103 | + $request = $this->gateway->capture($this->options); |
| 104 | + |
| 105 | + $this->assertInstanceOf(TransactionStatusRequest::class, $request); |
| 106 | + } |
| 107 | + |
| 108 | + /** |
| 109 | + * Tests if Gateway::refund will return an instance of RefundRequest. |
| 110 | + */ |
| 111 | + public function testRefund(): void |
| 112 | + { |
| 113 | + $request = $this->gateway->refund($this->options); |
| 114 | + |
| 115 | + $this->assertInstanceOf(RefundRequest::class, $request); |
| 116 | + } |
| 117 | + |
60 | 118 | /**
|
61 | 119 | * Returns the test cases for @see testInitializeSetsBaseUrlBasedOnTestMode.
|
62 | 120 | *
|
|
0 commit comments