2026-09-30 12:08:22 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-11-10 14:28:00 +01:00
|
|
|
use App\Cqs\Queries\PickupExceptions\GetPaginatedPickupExceptionsQuery;
|
|
|
|
|
use App\Cqs\Queries\PickupExceptions\GetPaginatedPickupExceptionsQueryInput;
|
2026-09-30 12:08:22 +02:00
|
|
|
use App\Dto\PickupExceptionDto;
|
|
|
|
|
use App\Models\PickupException;
|
|
|
|
|
use App\Services\DataTableService;
|
|
|
|
|
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
|
|
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
2026-10-02 12:14:48 +02:00
|
|
|
use Shared\Pagination\PageNumber;
|
|
|
|
|
use Shared\Pagination\PageSize;
|
|
|
|
|
use Shared\Pagination\Pagination;
|
2026-09-30 12:08:22 +02:00
|
|
|
|
|
|
|
|
uses(RefreshDatabase::class);
|
|
|
|
|
|
|
|
|
|
describe('GetPaginatedPickupExceptionsQuery', function () {
|
|
|
|
|
test('it executes and returns paginated pickup exception DTOs', function () {
|
|
|
|
|
// GIVEN
|
|
|
|
|
PickupException::factory()->count(3)->create();
|
|
|
|
|
|
|
|
|
|
$dataTableService = resolve(DataTableService::class);
|
|
|
|
|
$query = new GetPaginatedPickupExceptionsQuery($dataTableService);
|
|
|
|
|
$input = new GetPaginatedPickupExceptionsQueryInput(
|
2026-10-02 12:14:48 +02:00
|
|
|
pagination: Pagination::ofPage(new PageNumber(1), new PageSize(10)),
|
2026-09-30 12:08:22 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$paginator = $query($input);
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
expect($paginator)->toBeInstanceOf(LengthAwarePaginator::class)
|
|
|
|
|
->and($paginator->total())->toBe(3)
|
|
|
|
|
->and($paginator->items())->toHaveCount(3)
|
|
|
|
|
->and($paginator->items()[0])->toBeInstanceOf(PickupExceptionDto::class);
|
|
|
|
|
});
|
|
|
|
|
});
|