53 lines
1.6 KiB
PHP
53 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Presentation\Api\V1\Presenters\Employees;
|
|
|
|
use Application\Arcadia\Usecase\Employees\FindAll\Output;
|
|
use Application\Arcadia\Usecase\Employees\FindAll\PaginatedEmployee;
|
|
use Domain\Models\ValueObjects\Employees\SiRhMatricule;
|
|
use Presentation\Api\V1\Presenters\Employees\EmployeesIndexPresenter;
|
|
use Presentation\Api\V1\Presenters\Employees\EmployeesIndexView;
|
|
|
|
covers(
|
|
EmployeesIndexPresenter::class,
|
|
EmployeesIndexView::class,
|
|
);
|
|
|
|
describe('EmployeesIndexPresenter Unit Tests', function (): void {
|
|
it('transforms Output into EmployeesIndexView', function (): void {
|
|
// GIVEN
|
|
$employee = new PaginatedEmployee(
|
|
id: new SiRhMatricule('1234567'),
|
|
firstName: 'Jean',
|
|
lastName: 'DUPONT',
|
|
establishment: '01',
|
|
site: 'LDCSER',
|
|
service: '097',
|
|
startDate: new \DateTimeImmutable('2024-01-01'),
|
|
endDate: null,
|
|
plannedEndDate: null,
|
|
);
|
|
|
|
$output = new Output(
|
|
employees: [$employee],
|
|
total: 1,
|
|
page: 1,
|
|
perPage: 25,
|
|
);
|
|
|
|
$presenter = new EmployeesIndexPresenter();
|
|
|
|
// WHEN
|
|
$view = $presenter->present($output);
|
|
|
|
// THEN
|
|
expect($view)->toBeInstanceOf(EmployeesIndexView::class)
|
|
->and($view->employees)->toHaveCount(1)
|
|
->and($view->employees[0])->toBe($employee)
|
|
->and($view->total)->toBe(1)
|
|
->and($view->page)->toBe(1)
|
|
->and($view->perPage)->toBe(25);
|
|
});
|
|
});
|