Skip to content

Commit 5d95d02

Browse files
committed
Add basic success test with additional request structure validation
1 parent aae12f0 commit 5d95d02

File tree

2 files changed

+64
-4
lines changed

2 files changed

+64
-4
lines changed

tests/GatewayTest.php

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ public function setUp(): void
2525
'returnUrl' => 'https://www.example.com/return',
2626
'transactionId' => '123abc',
2727
'testMode' => true,
28-
'card' => [
29-
'email' => "[email protected]",
30-
'name' => "ABCDE FGHIJK",
31-
'phone' => "123 456 7890",
28+
'card' => [
29+
'email' => "[email protected]",
30+
'name' => "ABCDE FGHIJK",
31+
'phone' => "123 456 7890",
3232
'shippingAddress1' => "Ship 1 Test",
3333
'shippingAddress2' => "Ship 2 Test",
3434
'shippingCity' => "Ship 4 City",
@@ -44,4 +44,45 @@ public function setUp(): void
4444
],
4545
];
4646
}
47+
48+
public function testPurchaseSuccess()
49+
{
50+
$this->setMockHttpResponse('PurchaseSuccess.txt');
51+
52+
$options = $this->options + ['type' => 'purchase'];
53+
$request = $this->gateway->purchase($options);
54+
55+
$data = $request->getData();
56+
$this->assertSame('[email protected]', $data['customer']['email']);
57+
$this->assertSame('ABCDE FGHIJK', $data['customer']['billing']['name']);
58+
$this->assertSame('Bill 1 Test', $data['customer']['billing']['address1']);
59+
$this->assertSame('Bill 2 Test', $data['customer']['billing']['address2']);
60+
$this->assertSame('Bill 4 City', $data['customer']['billing']['city']);
61+
$this->assertSame('Bill 7 Country', $data['customer']['billing']['countryCode']);
62+
$this->assertSame('Bill 5 Postcode', $data['customer']['billing']['postalCode']);
63+
$this->assertSame('123 456 7890', $data['customer']['billing']['phoneNumber']);
64+
$this->assertSame('Bill 6 State', $data['customer']['billing']['state']);
65+
$this->assertSame('ABCDE FGHIJK', $data['customer']['shipping']['name']);
66+
$this->assertSame('Ship 1 Test', $data['customer']['shipping']['address1']);
67+
$this->assertSame('Ship 2 Test', $data['customer']['shipping']['address2']);
68+
$this->assertSame('Ship 4 City', $data['customer']['shipping']['city']);
69+
$this->assertSame('Ship 7 Country', $data['customer']['shipping']['countryCode']);
70+
$this->assertSame('Ship 5 Postcode', $data['customer']['shipping']['postalCode']);
71+
$this->assertSame('123 456 7890', $data['customer']['shipping']['phoneNumber']);
72+
$this->assertSame('Ship 6 State', $data['customer']['shipping']['state']);
73+
74+
$response = $request->send();
75+
76+
$this->assertFalse($response->isSuccessful());
77+
$this->assertTrue($response->isRedirect());
78+
$this->assertNull($response->getTransactionReference());
79+
$this->assertNull($response->getMessage());
80+
$this->assertSame('GET', $response->getRedirectMethod());
81+
$this->assertSame(
82+
'https://uat.windcave.com/pxmi3/EF4054F622D6C4C1B5D0F260ED2B2C143C1EDCADD7A86374ED601212E11C409319CD439CC8082194B',
83+
$response->getRedirectUrl()
84+
);
85+
$this->assertSame([], $response->getRedirectData());
86+
}
87+
4788
}

tests/Mock/PurchaseSuccess.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
HTTP/1.1 200 OK
2+
Date: Thu, 10 November 2025 01:23:45 GMT
3+
Content-Type: application/json; charset=utf-8
4+
5+
{
6+
"id": "Kdjc6dikdiodkdjsudjj53nr63uj6s42",
7+
"state": "init",
8+
"links": [
9+
{
10+
"href": "https://uat.windcave.com/pxmi3/EF4054F622D6C4C1B5D0F260ED2B2C143C1EDCADD7A86374ED601212E11C409319CD439CC8082194B",
11+
"rel": "hpp",
12+
"method": "REDIRECT"
13+
}
14+
],
15+
"transactions": [
16+
{}
17+
],
18+
"customerId": "32424324"
19+
}

0 commit comments

Comments
 (0)