ldc-cocotte/tests/Integration/WithApp/App/Queries/Ranges/GetPaginatedRangesQueryTest.php
Jérémy Munsch 42bdae01cc
feat: implement pagination using Pagination value object
- Updated DataTableService to accept a Pagination object for pagination parameters.
- Refactored paginateQuery method to utilize pageSize and pageNumber from Pagination.

refactor: replace ActionExecutor with Executor in controller traits

- Updated ChangesModelOrder, TogglesModelStar, and TogglesModelStatus traits to use Executor interface instead of ActionExecutor.

feat: add PictureMetadata and Slug value objects

- Introduced PictureMetadata for managing image metadata with validation.
- Added Slug value object for slug generation and validation.

feat: update breadcrumbs to support RangeDto

- Modified breadcrumbs-bo.php to accept RangeDto in the edit route.

test: add tests for RangesController

- Added tests for accessing, creating, updating, and deleting ranges.
- Included tests for toggling range status.

test: add integration tests for range actions

- Created tests for CreateRange, DeleteRange, and UpdateRange actions.
- Validated input handling and database interactions.

test: add unit tests for range input classes

- Implemented tests for CreateRangeInput and UpdateRangeInput to validate input constraints.

test: add unit tests for value objects

- Added tests for PictureMetadata and Slug to ensure proper validation and instantiation.

test: add unit tests for RangeDto

- Created tests to verify RangeDto mapping from Range model.

test: add unit tests for RangePolicy

- Implemented tests for RangePolicy to validate permissions based on user roles.
2026-10-27 09:58:34 +01:00

42 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
use App\Dto\RangeDto;
use App\Models\Range;
use App\Queries\Ranges\GetPaginatedRangesQuery;
use App\Services\DataTableService;
use Illuminate\Foundation\Testing\RefreshDatabase;
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);
// WHEN
$result = $query->execute();
// 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);
});
});