2026-11-10 18:08:41 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-11-16 14:18:42 +01:00
|
|
|
namespace Tests\Unit\App\Cqs\Actions\Employee;
|
|
|
|
|
|
2026-11-10 19:29:20 +01:00
|
|
|
use App\Cqs\Actions\Employee\ImportEmployeesOutput;
|
2026-11-10 18:08:41 +01:00
|
|
|
|
2026-11-10 19:29:20 +01:00
|
|
|
describe('ImportEmployeesOutput', function (): void {
|
2026-11-10 18:08:41 +01:00
|
|
|
it('stores valid counters and errors', function (): void {
|
|
|
|
|
// GIVEN + WHEN
|
2026-11-10 19:29:20 +01:00
|
|
|
$result = new ImportEmployeesOutput(
|
2026-11-10 18:08:41 +01:00
|
|
|
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
|
2026-11-10 19:29:20 +01:00
|
|
|
expect(fn () => new ImportEmployeesOutput(-1, 0, []))
|
2026-11-10 18:08:41 +01:00
|
|
|
->toThrow(\InvalidArgumentException::class);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('throws when updated count is negative', function (): void {
|
|
|
|
|
// GIVEN + WHEN + THEN
|
2026-11-10 19:29:20 +01:00
|
|
|
expect(fn () => new ImportEmployeesOutput(0, -1, []))
|
2026-11-10 18:08:41 +01:00
|
|
|
->toThrow(\InvalidArgumentException::class);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('throws when errors contain non string values', function (): void {
|
|
|
|
|
// GIVEN + WHEN + THEN
|
2026-11-10 19:29:20 +01:00
|
|
|
expect(fn () => new ImportEmployeesOutput(0, 0, ['ok', 123])) // @phpstan-ignore argument.type
|
2026-11-10 18:08:41 +01:00
|
|
|
->toThrow(\InvalidArgumentException::class);
|
|
|
|
|
});
|
|
|
|
|
});
|