- Use cases: FindAllIncoSheets & FindIncoSheet (filters, pagination, short projection) - Presentation: controllers, FormRequests with scalar validation, DTOs (camelCase) - Ports & Adapters: IncoSheetDirectory & EloquentIncoSheetDirectory - Tests: Pest 4 unit, integration, OpenAPI spectator conformance, dynamic arch tests - Docs: updated Bruno collection and OpenAPI spec
59 lines
1.9 KiB
PHP
59 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Application\Usecase\Employees;
|
|
|
|
use Application\Usecase\Employees\FindAll\Filter;
|
|
use Application\Usecase\Employees\FindAll\Input;
|
|
use Application\Usecase\Employees\FindAll\SortColumn;
|
|
use Application\Usecase\Employees\FindAll\Sorter;
|
|
use Domain\Models\ValueObjects\EstablishmentCode;
|
|
use Domain\Models\ValueObjects\ServiceId;
|
|
use Domain\Models\ValueObjects\SiteId;
|
|
use Shared\Pagination;
|
|
|
|
covers(
|
|
Filter::class,
|
|
Input::class,
|
|
SortColumn::class,
|
|
Sorter::class
|
|
);
|
|
|
|
describe('FindAllEmployees Application DTOs Unit Tests', function (): void {
|
|
it('instantiates Filter correctly when parameters are provided', function (): void {
|
|
// GIVEN
|
|
$establishment = new EstablishmentCode('01');
|
|
$service = new ServiceId('097');
|
|
$since = new \DateTimeImmutable('2024-01-01');
|
|
$site = new SiteId('LDCSER');
|
|
|
|
// WHEN
|
|
$filter = new Filter($establishment, $service, $since, $site);
|
|
|
|
// THEN
|
|
expect($filter->establishment)->toBe($establishment)
|
|
->and($filter->service)->toBe($service)
|
|
->and($filter->since)->toBe($since)
|
|
->and($filter->sites)->toBe([$site]);
|
|
});
|
|
|
|
it('throws InvalidArgumentException for empty Filter parameters', function (): void {
|
|
expect(fn () => new Filter(null, null, null))
|
|
->toThrow(\InvalidArgumentException::class, 'Filter requires at least one filtering criterion.');
|
|
});
|
|
|
|
it('instantiates Input DTO', function (): void {
|
|
// GIVEN
|
|
$pagination = Pagination::ofPage(1, 25);
|
|
$sorter = new Sorter(SortColumn::arcadiaId, \SortDirection::Ascending);
|
|
|
|
// WHEN
|
|
$input = new Input($pagination, $sorter);
|
|
|
|
// THEN
|
|
expect($input->pagination)->toBe($pagination)
|
|
->and($input->sorter)->toBe($sorter)
|
|
->and($input->filter)->toBeNull();
|
|
});
|
|
});
|