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