@@ -36,7 +36,7 @@ public function testPay(): void
3636 // With MerchantFeeDeductible, customer pays only the product price (no fee added)
3737 $ productPrice = $ product ->getAmountProduct ($ buyer );
3838 $ fee = (int ) $ math ->div ($ math ->mul ($ productPrice , $ product ->getFeePercent ()), 100 );
39-
39+
4040 // Customer only needs to deposit the product price
4141 $ balance = $ productPrice ;
4242
@@ -45,7 +45,6 @@ public function testPay(): void
4545
4646 self ::assertNotSame (0 , $ buyer ->balanceInt );
4747 $ transfer = $ buyer ->pay ($ product );
48- self ::assertNotNull ($ transfer );
4948
5049 $ withdraw = $ transfer ->withdraw ;
5150 $ deposit = $ transfer ->deposit ;
@@ -73,11 +72,12 @@ public function testPay(): void
7372
7473 public function testGift (): void
7574 {
76- /**
77- * @var Buyer $santa
78- * @var Buyer $child
79- */
80- [$ santa , $ child ] = BuyerFactory::times (2 )->create ();
75+ /** @var \Illuminate\Database\Eloquent\Collection<int, Buyer> $buyers */
76+ $ buyers = BuyerFactory::times (2 )->create ();
77+ /** @var Buyer $santa */
78+ $ santa = $ buyers [0 ];
79+ /** @var Buyer $child */
80+ $ child = $ buyers [1 ];
8181 /** @var ItemMerchantFeeDeductible $product */
8282 $ product = ItemMerchantFeeDeductibleFactory::new ()->create ([
8383 'quantity ' => 1 ,
@@ -88,7 +88,7 @@ public function testGift(): void
8888
8989 $ productPrice = $ product ->getAmountProduct ($ santa );
9090 $ fee = (int ) $ math ->div ($ math ->mul ($ productPrice , $ product ->getFeePercent ()), 100 );
91-
91+
9292 // With MerchantFeeDeductible, customer pays only the product price
9393 $ balance = $ productPrice ;
9494
@@ -99,7 +99,6 @@ public function testGift(): void
9999 self ::assertNotSame ($ santa ->balanceInt , 0 );
100100 self ::assertSame ($ child ->balanceInt , 0 );
101101 $ transfer = $ santa ->wallet ->gift ($ child , $ product );
102- self ::assertNotNull ($ transfer );
103102
104103 $ withdraw = $ transfer ->withdraw ;
105104 $ deposit = $ transfer ->deposit ;
@@ -131,11 +130,12 @@ public function testGiftFail(): void
131130 $ this ->expectExceptionCode (ExceptionInterface::INSUFFICIENT_FUNDS );
132131 $ this ->expectExceptionMessageStrict (trans ('wallet::errors.insufficient_funds ' ));
133132
134- /**
135- * @var Buyer $santa
136- * @var Buyer $child
137- */
138- [$ santa , $ child ] = BuyerFactory::times (2 )->create ();
133+ /** @var \Illuminate\Database\Eloquent\Collection<int, Buyer> $buyers */
134+ $ buyers = BuyerFactory::times (2 )->create ();
135+ /** @var Buyer $santa */
136+ $ santa = $ buyers [0 ];
137+ /** @var Buyer $child */
138+ $ child = $ buyers [1 ];
139139 /** @var ItemMerchantFeeDeductible $product */
140140 $ product = ItemMerchantFeeDeductibleFactory::new ()->create ([
141141 'price ' => 200 ,
@@ -173,12 +173,11 @@ public function testPayWithExactAmount(): void
173173 $ buyer ->deposit ($ productPrice );
174174 self ::assertSame ($ buyer ->balanceInt , $ productPrice );
175175
176- $ transfer = $ buyer ->pay ($ product );
177- self ::assertNotNull ($ transfer );
176+ $ buyer ->pay ($ product );
178177
179178 // Customer balance should be 0 after payment
180179 self ::assertSame ($ buyer ->balanceInt , 0 );
181-
180+
182181 // Merchant should receive product price minus fee
183182 $ expectedMerchantAmount = $ productPrice - $ fee ;
184183 self ::assertSame ($ product ->balanceInt , $ expectedMerchantAmount );
@@ -216,19 +215,17 @@ public function testPayMultiWallet(): void
216215
217216 // Pay from first wallet
218217 $ transfer1 = $ wallet1 ->pay ($ product );
219- self ::assertNotNull ($ transfer1 );
220218 self ::assertSame ($ transfer1 ->status , Transfer::STATUS_PAID );
221219 self ::assertSame ($ wallet1 ->balanceInt , 0 );
222-
220+
223221 $ expectedMerchantAmount1 = $ productPrice1 - $ fee1 ;
224222 self ::assertSame ($ product ->balanceInt , $ expectedMerchantAmount1 );
225223
226224 // Pay from second wallet
227225 $ transfer2 = $ wallet2 ->pay ($ product );
228- self ::assertNotNull ($ transfer2 );
229226 self ::assertSame ($ transfer2 ->status , Transfer::STATUS_PAID );
230227 self ::assertSame ($ wallet2 ->balanceInt , 0 );
231-
228+
232229 $ expectedMerchantAmount2 = $ productPrice2 - $ fee2 ;
233230 self ::assertSame ($ product ->balanceInt , $ expectedMerchantAmount1 + $ expectedMerchantAmount2 );
234231
@@ -247,11 +244,12 @@ public function testPayMultiWallet(): void
247244
248245 public function testTransfer (): void
249246 {
250- /**
251- * @var Buyer $from
252- * @var Buyer $to
253- */
254- [$ from , $ to ] = BuyerFactory::times (2 )->create ();
247+ /** @var \Illuminate\Database\Eloquent\Collection<int, Buyer> $buyers */
248+ $ buyers = BuyerFactory::times (2 )->create ();
249+ /** @var Buyer $from */
250+ $ from = $ buyers [0 ];
251+ /** @var Buyer $to */
252+ $ to = $ buyers [1 ];
255253
256254 $ math = app (MathServiceInterface::class);
257255 $ amount = 100 ;
@@ -274,22 +272,19 @@ public function testTransfer(): void
274272 // Transfer from buyer to product (merchant)
275273 // With MerchantFeeDeductible, the merchant receives amount minus fee
276274 $ transfer = $ from ->transfer ($ product , $ amount );
277- self ::assertNotNull ($ transfer );
278275 self ::assertSame ($ transfer ->status , Transfer::STATUS_TRANSFER );
279276
280277 // From wallet should be empty
281278 self ::assertSame ($ from ->balanceInt , 0 );
282-
279+
283280 // Product (merchant) should receive amount minus fee
284281 $ expectedMerchantAmount = $ amount - $ fee ;
285282 self ::assertSame ($ product ->balanceInt , $ expectedMerchantAmount );
286283 self ::assertSame ((int ) $ transfer ->fee , $ fee );
287284
288285 // Transfer back from product to buyer
289- $ transferBack = $ product ->transfer ($ from , $ product ->balanceInt );
290- self ::assertNotNull ($ transferBack );
286+ $ product ->transfer ($ from , $ product ->balanceInt );
291287 self ::assertSame ($ from ->balanceInt , $ expectedMerchantAmount );
292288 self ::assertSame ($ product ->balanceInt , 0 );
293289 }
294290}
295-
0 commit comments