42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
use App\Actions\PickupExceptions\DeletePickupException;
|
||
|
|
use App\Actions\PickupExceptions\DeletePickupExceptionInput;
|
||
|
|
use App\Contracts\ActionInput;
|
||
|
|
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);
|
||
|
|
});
|
||
|
|
});
|