test(stock): cover authoritative reservation expiration
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Tests\Unit\Purchase;
|
||||
|
||||
use App\Domains\Catalog\Models\StockReservation;
|
||||
use App\Domains\Purchase\Exceptions\PurchaseExpiredException;
|
||||
use App\Domains\Purchase\Models\Purchase;
|
||||
use App\Domains\Purchase\Services\PurchaseStateGuard;
|
||||
@@ -22,7 +23,6 @@ class PurchaseStateGuardTest extends TestCase
|
||||
{
|
||||
$purchase = (new Purchase)->forceFill([
|
||||
'status' => Purchase::STATUS_EXPIRED,
|
||||
'expires_at' => null,
|
||||
]);
|
||||
|
||||
$this->expectException(PurchaseExpiredException::class);
|
||||
@@ -34,8 +34,11 @@ class PurchaseStateGuardTest extends TestCase
|
||||
{
|
||||
$purchase = (new Purchase)->forceFill([
|
||||
'status' => Purchase::STATUS_PENDING_PAYMENT,
|
||||
'expires_at' => now()->subMinute(),
|
||||
]);
|
||||
$purchase->setRelation('stockReservation', (new StockReservation)->forceFill([
|
||||
'status' => StockReservation::STATUS_ACTIVE,
|
||||
'expires_at' => now()->subMinute(),
|
||||
]));
|
||||
|
||||
$this->expectException(PurchaseExpiredException::class);
|
||||
|
||||
@@ -46,8 +49,11 @@ class PurchaseStateGuardTest extends TestCase
|
||||
{
|
||||
$purchase = (new Purchase)->forceFill([
|
||||
'status' => Purchase::STATUS_PAID,
|
||||
'expires_at' => now()->subMinute(),
|
||||
]);
|
||||
$purchase->setRelation('stockReservation', (new StockReservation)->forceFill([
|
||||
'status' => StockReservation::STATUS_ACTIVE,
|
||||
'expires_at' => now()->subMinute(),
|
||||
]));
|
||||
|
||||
$this->guard->assertNotExpired($purchase);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user