ldc-cocotte/tests/Unit/App/Cqs/Actions/Employee/ImportEmployeesOutputTest.php
2026-11-16 14:18:42 +01:00

41 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Unit\App\Cqs\Actions\Employee;
use App\Cqs\Actions\Employee\ImportEmployeesOutput;
describe('ImportEmployeesOutput', function (): void {
it('stores valid counters and errors', function (): void {
// GIVEN + WHEN
$result = new ImportEmployeesOutput(
insertedCount: 3,
updatedCount: 4,
errors: ['Invalid date at line 3'],
);
// THEN
expect($result->insertedCount)->toBe(3)
->and($result->updatedCount)->toBe(4)
->and($result->errors)->toBe(['Invalid date at line 3']);
});
it('throws when inserted count is negative', function (): void {
// GIVEN + WHEN + THEN
expect(fn () => new ImportEmployeesOutput(-1, 0, []))
->toThrow(\InvalidArgumentException::class);
});
it('throws when updated count is negative', function (): void {
// GIVEN + WHEN + THEN
expect(fn () => new ImportEmployeesOutput(0, -1, []))
->toThrow(\InvalidArgumentException::class);
});
it('throws when errors contain non string values', function (): void {
// GIVEN + WHEN + THEN
expect(fn () => new ImportEmployeesOutput(0, 0, ['ok', 123])) // @phpstan-ignore argument.type
->toThrow(\InvalidArgumentException::class);
});
});