ldc-cocotte/tests/Integration/WithApp/App/Actions/PickupExceptions/DeletePickupExceptionTest.php

42 lines
1.2 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
use App\Contracts\ActionInput;
use App\Cqs\Actions\PickupExceptions\DeletePickupException;
use App\Cqs\Actions\PickupExceptions\DeletePickupExceptionInput;
use App\Models\PickupException;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
describe('DeletePickupException action', function () {
test('it deletes a pickup exception from database', function () {
// GIVEN
$pickupException = PickupException::factory()->create();
$action = new DeletePickupException();
$input = new DeletePickupExceptionInput(
pickupException: $pickupException,
);
// WHEN
$result = $action($input);
// THEN
expect($result)->toBeTrue();
expect(PickupException::query()->find($pickupException->id))->toBeNull();
});
test('it throws when an invalid input is passed', function () {
// GIVEN
$action = new DeletePickupException();
$invalidInput = new class () implements ActionInput
{
};
// WHEN & THEN
expect(fn () => $action($invalidInput))->toThrow(\InvalidArgumentException::class);
});
});