@@ -14,13 +14,13 @@ public function testConstructorMapsPayloadObject(): void
1414 {
1515 $ payload = [
1616 'object ' => [
17- 'id ' => 'PO-123 ' ,
18- 'description ' => 'Test order ' ,
19- 'reference ' => 'REF-999 ' ,
20- 'status ' => ['code ' => 200 , 'action ' => 'PAID ' ],
21- 'amount ' => ['value ' => 1000 , 'currency ' => 'EUR ' ],
22- 'capturedAmount ' => ['value ' => 500 , 'currency ' => 'EUR ' ],
23- 'authorizedAmount ' => ['value ' => 1000 , 'currency ' => 'EUR ' ],
17+ 'id ' => 'PO-123 ' ,
18+ 'description ' => 'Test order ' ,
19+ 'reference ' => 'REF-999 ' ,
20+ 'status ' => ['code ' => 200 , 'action ' => 'PAID ' ],
21+ 'amount ' => ['value ' => 1000 , 'currency ' => 'EUR ' ],
22+ 'capturedAmount ' => ['value ' => 500 , 'currency ' => 'EUR ' ],
23+ 'authorizedAmount ' => ['value ' => 1000 , 'currency ' => 'EUR ' ],
2424 ],
2525 ];
2626
@@ -42,7 +42,7 @@ public function testAmountRefundedIsNullWhenNotSet(): void
4242
4343 public function testAmountRefundedReturnsValueInUnits (): void
4444 {
45- $ order = new PayOrder ();
45+ $ order = new PayOrder ();
4646 $ amount = new Amount (1234 , 'EUR ' );
4747
4848 $ order ->setAmountRefunded ($ amount );
@@ -124,6 +124,7 @@ public function testPaymentHelpersReturnNullWhenNoPayments(): void
124124 $ this ->assertNull ($ order ->getPaymentMethod ());
125125 $ this ->assertNull ($ order ->getCustomerId ());
126126 $ this ->assertNull ($ order ->getCustomerName ());
127+ $ this ->assertSame ([], $ order ->getPayments ());
127128 }
128129
129130 public function testIsTestmodeTrueWhenIntegrationTestFlagTrue (): void
@@ -146,6 +147,13 @@ public function testIsTestmodeFalseWhenIntegrationTestFlagMissingOrFalse(): void
146147 $ this ->assertFalse ($ order ->isTestmode ());
147148 }
148149
150+ public function testCheckoutDataReturnsEmptyArrayWhenNotSet (): void
151+ {
152+ $ order = new PayOrder ();
153+
154+ $ this ->assertSame ([], $ order ->getCheckoutData ());
155+ }
156+
149157 public function testAmountAndCurrency (): void
150158 {
151159 $ order = new PayOrder ();
@@ -157,6 +165,21 @@ public function testAmountAndCurrency(): void
157165 $ this ->assertSame ('EUR ' , $ order ->getCurrency ());
158166 }
159167
168+ public function testAuthorizedAndCapturedAmountGettersAndSetters (): void
169+ {
170+ $ order = new PayOrder ();
171+ $ authorized = new Amount (1000 , 'EUR ' );
172+ $ captured = new Amount (500 , 'EUR ' );
173+
174+ $ this ->assertNull ($ order ->getAuthorizedAmount ());
175+ $ this ->assertNull ($ order ->getCapturedAmount ());
176+
177+ $ order ->setAuthorizedAmount ($ authorized );
178+ $ order ->setCapturedAmount ($ captured );
179+
180+ $ this ->assertSame ($ authorized , $ order ->getAuthorizedAmount ());
181+ $ this ->assertSame ($ captured , $ order ->getCapturedAmount ());
182+ }
160183
161184 public function testPaymentAndStatusUrls (): void
162185 {
@@ -192,8 +215,53 @@ public function testTransferDataGetterAndSetter(): void
192215 $ data = ['some ' => 'value ' , 'foo ' => 'bar ' ];
193216
194217 $ order ->setTransferData ($ data );
195-
196218 $ this ->assertSame ($ data , $ order ->getTransferData ());
219+
220+ $ order ->setTransferData (null );
221+ $ this ->assertNull ($ order ->getTransferData ());
197222 }
198223
224+ public function testStatsGettersReturnNullWhenNotSet (): void
225+ {
226+ $ order = new PayOrder ();
227+
228+ // Typed property $stats is not initialized unless setStats() is called
229+ $ order ->setStats ([]);
230+
231+ $ this ->assertSame ([], $ order ->getStats ());
232+ $ this ->assertNull ($ order ->getExtra1 ());
233+ $ this ->assertNull ($ order ->getExtra2 ());
234+ $ this ->assertNull ($ order ->getExtra3 ());
235+ $ this ->assertNull ($ order ->getTool ());
236+ $ this ->assertNull ($ order ->getInfo ());
237+ $ this ->assertNull ($ order ->getObject ());
238+ $ this ->assertNull ($ order ->getDomainId ());
239+ }
240+
241+
242+ public function testStatsGettersReturnValuesWhenSet (): void
243+ {
244+ $ order = new PayOrder ();
245+
246+ $ stats = [
247+ 'extra1 ' => 'E1 ' ,
248+ 'extra2 ' => 'E2 ' ,
249+ 'extra3 ' => 'E3 ' ,
250+ 'tool ' => 'api ' ,
251+ 'info ' => ['k ' => 'v ' ],
252+ 'object ' => 'order ' ,
253+ 'domainId ' => 123 ,
254+ ];
255+
256+ $ order ->setStats ($ stats );
257+
258+ $ this ->assertSame ($ stats , $ order ->getStats ());
259+ $ this ->assertSame ('E1 ' , $ order ->getExtra1 ());
260+ $ this ->assertSame ('E2 ' , $ order ->getExtra2 ());
261+ $ this ->assertSame ('E3 ' , $ order ->getExtra3 ());
262+ $ this ->assertSame ('api ' , $ order ->getTool ());
263+ $ this ->assertSame (['k ' => 'v ' ], $ order ->getInfo ());
264+ $ this ->assertSame ('order ' , $ order ->getObject ());
265+ $ this ->assertSame (123 , $ order ->getDomainId ());
266+ }
199267}
0 commit comments