Skip to content

Commit a87ba14

Browse files
committed
add test getQuantity
1 parent 59cb7d3 commit a87ba14

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tests/Units/Domain/ProductTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,10 @@ public function testPayCustomPrice(): void
265265
{
266266
/**
267267
* @var Buyer $buyer
268-
* @var Item $product
268+
* @var Item $productIn
269269
*/
270270
$buyer = BuyerFactory::new()->create();
271-
$product = ItemFactory::new()->create([
271+
[$productIn, $productOutside] = ItemFactory::times(2)->create([
272272
'quantity' => 2,
273273
'price' => 5_000,
274274
]);
@@ -279,13 +279,15 @@ public function testPayCustomPrice(): void
279279
self::assertSame(6_000 + (int) $buyer->getKey(), $buyer->balanceInt);
280280

281281
$cart = app(Cart::class)
282-
->withItem($product, pricePerItem: 1_000)
283-
->withItem($product)
282+
->withItem($productIn, pricePerItem: 1_000)
283+
->withItem($productIn)
284284
;
285285

286286
self::assertSame(6_000 + (int) $buyer->getKey(), (int) $cart->getTotal($buyer));
287287

288288
$transfers = $buyer->payCart($cart);
289+
self::assertSame(0, $cart->getQuantity($productOutside));
290+
self::assertSame(2, $cart->getQuantity($productIn));
289291
self::assertSame(0, $buyer->balanceInt);
290292
self::assertCount(2, $transfers);
291293
}

0 commit comments

Comments
 (0)