ldc-cocotte/tests/Unit/App/Actions/Common/ChangeModelOrderPositionInputTest.php
Jérémy Munsch d0efb0f527
refactor: update namespaces for actions and queries
Refactored the codebase to change the namespaces of various actions and queries from `App\Actions` to `App\Cqs\Actions` and `App\Queries` to `App\Cqs\Queries`. This restructuring improves organization and clarity in the codebase.
2026-11-10 15:13:26 +01:00

50 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
use App\Cqs\Actions\Common\ChangeModelOrderPositionInput;
use App\Interfaces\ModelWithOrder;
use Illuminate\Database\Eloquent\Model;
describe('ChangeModelOrderPositionInput', function (): void {
it('can be instantiated with a model implementing ModelWithOrder and a valid target order', function (): void {
// GIVEN
$mock = new class () extends Model implements ModelWithOrder
{
public function getOrder(): int
{
return 1;
}
public function setOrder(int $order): void
{
}
};
// WHEN
$input = new ChangeModelOrderPositionInput(model: $mock, targetOrder: 5);
// THEN
expect($input->model)->toBe($mock)
->and($input->targetOrder)->toBe(5);
});
it('throws when target order is less than 1', function (): void {
// GIVEN
$mock = new class () extends Model implements ModelWithOrder
{
public function getOrder(): int
{
return 1;
}
public function setOrder(int $order): void
{
}
};
// WHEN & THEN
expect(fn () => new ChangeModelOrderPositionInput(model: $mock, targetOrder: 0))
->toThrow(\InvalidArgumentException::class);
});
});