ldc-cocotte/tests/Integration/WithApp/App/Queries/Ranges/GetPaginatedRangesQueryTest.php
Jérémy Munsch 8b96ce90be
test(casts): add tests for EmployeeSitesCast functionality
test(casts): add tests for ShopperEstablishmentCodeCast functionality

test(casts): add tests for ShopperServiceCodeCast functionality

test(casts): add tests for ShopperSiteCodeCast functionality

test(dto): update ProductDtoTest to include additional fields

test(dto): update SettingDtoTest to remove arcadiaSites assertions

test(events): update AnOrderHasBeenPlacedTest to use value objects

test(entities): update OrderTest to use value objects for employee details

test(value-objects): update EmployeeUpsertDataTest to use value objects

test(pagination): update PaginationTest to access value properties

test(services): update AppCustomerAuthServiceTest to use CrmHashcode

test(services): update CrmServiceTest to use CrmHashcode for customer retrieval
2026-10-27 09:58:45 +01:00

49 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
use App\Dto\RangeDto;
use App\Models\Range;
use App\Queries\Ranges\GetPaginatedRangesQuery;
use App\Queries\Ranges\GetPaginatedRangesQueryInput;
use App\Services\DataTableService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Shared\Pagination\PageNumber;
use Shared\Pagination\PageSize;
use Shared\Pagination\Pagination;
uses(RefreshDatabase::class);
describe('GetPaginatedRangesQuery', function () {
test('it executes and returns paginated RangeDto collection', function () {
// GIVEN
$range1 = new Range();
$range1->name = 'Gamme Alpha';
$range1->picture_alt = 'Alt 1';
$range1->picture_title = 'Title 1';
$range1->status = true;
$range1->save();
$range2 = new Range();
$range2->name = 'Gamme Beta';
$range2->picture_alt = 'Alt 2';
$range2->picture_title = 'Title 2';
$range2->status = true;
$range2->save();
$dataTableService = resolve(DataTableService::class);
$query = new GetPaginatedRangesQuery($dataTableService);
$input = new GetPaginatedRangesQueryInput(
pagination: Pagination::ofPage(new PageNumber(1), new PageSize(10)),
);
// WHEN
$result = $query($input);
// THEN
expect($result->total())->toBe(2)
->and($result->items())->toHaveCount(2)
->and($result->items()[0])->toBeInstanceOf(RangeDto::class)
->and($result->items()[1])->toBeInstanceOf(RangeDto::class);
});
});