Skip to content

Commit b7af7c5

Browse files
authored
Merge pull request #4 from superbrave/gateway-tests
Gateway tests
2 parents ac91b4c + 791ee3b commit b7af7c5

File tree

1 file changed

+61
-4
lines changed

1 file changed

+61
-4
lines changed

tests/GatewayTest.php

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,40 @@
33
namespace Omnipay\IcepayPayments;
44

55
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;
79

810
/**
911
* Tests the Icepay gateway.
1012
*/
11-
class GatewayTest extends TestCase
13+
class GatewayTest extends AbstractTestCase
1214
{
1315
/**
1416
* @var GatewayInterface
1517
*/
1618
public $gateway;
1719

20+
/**
21+
* @var array
22+
*/
23+
private $options;
24+
1825
/**
1926
* Creates a new Gateway instance for testing.
2027
*/
2128
protected function setUp(): void
2229
{
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+
];
2440
}
2541

2642
/**
@@ -50,13 +66,54 @@ public function testFetchTransactionParameters(): void
5066
$setter = 'set'.ucfirst($this->camelCase($key));
5167
$value = uniqid();
5268
$this->gateway->$setter($value);
69+
$this->assertSame($value, $this->gateway->$getter());
5370

5471
// request should have matching property, with correct value
5572
$request = $this->gateway->fetchTransaction();
56-
$this->assertSame($value, $request->$getter());
73+
$this->assertSame($this->gateway->$getter(), $request->$getter());
5774
}
5875
}
5976

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+
60117
/**
61118
* Returns the test cases for @see testInitializeSetsBaseUrlBasedOnTestMode.
62119
*

0 commit comments

Comments
 (0)