refactor(reservations): unify expiration command
This commit is contained in:
33
tests/Unit/Catalog/ExpireStockReservationsServiceTest.php
Normal file
33
tests/Unit/Catalog/ExpireStockReservationsServiceTest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Catalog;
|
||||
|
||||
use App\Domains\Cart\Services\ExpireCartReservationsService;
|
||||
use App\Domains\Catalog\Services\ExpireStockReservationsService;
|
||||
use App\Domains\Purchase\Services\CheckoutService;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ExpireStockReservationsServiceTest extends TestCase
|
||||
{
|
||||
public function test_it_expires_purchases_before_abandoned_cart_items(): void
|
||||
{
|
||||
$checkout = \Mockery::mock(CheckoutService::class);
|
||||
$checkout->shouldReceive('expireOverduePurchases')
|
||||
->once()
|
||||
->ordered()
|
||||
->andReturn(2);
|
||||
|
||||
$carts = \Mockery::mock(ExpireCartReservationsService::class);
|
||||
$carts->shouldReceive('expireOverdue')
|
||||
->once()
|
||||
->ordered()
|
||||
->andReturn(3);
|
||||
|
||||
$result = (new ExpireStockReservationsService($checkout, $carts))->expireOverdue();
|
||||
|
||||
$this->assertSame([
|
||||
'purchases' => 2,
|
||||
'cart_items' => 3,
|
||||
], $result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user