43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Integration\WithApp\App\Cqs\Actions\PickupExceptions;
|
|
|
|
use App\Contracts\ActionInput;
|
|
use App\Cqs\Actions\PickupExceptions\DeletePickupException;
|
|
use App\Cqs\Actions\PickupExceptions\DeletePickupExceptionInput;
|
|
use App\Models\PickupException;
|
|
|
|
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
|
|
{
|
|
};
|
|
|
|
/** @var \Closure(\App\Contracts\ActionInput): mixed $callable */
|
|
$callable = \Closure::fromCallable($action);
|
|
|
|
// WHEN & THEN
|
|
expect(fn () => $callable($invalidInput))->toThrow(\InvalidArgumentException::class);
|
|
});
|
|
});
|