- 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
72 lines
2.1 KiB
PHP
72 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Domain;
|
|
|
|
use Domain\Models\ValueObjects\Entities\ArcadiaEmployeeId;
|
|
|
|
covers(ArcadiaEmployeeId::class);
|
|
|
|
describe('ArcadiaEmployeeId Value Object Instantiation', function (): void {
|
|
it('instantiates successfully with a valid 7-digit matricule', function (): void {
|
|
// GIVEN
|
|
$validMatricule = '0115590';
|
|
|
|
// WHEN
|
|
$employeeId = new ArcadiaEmployeeId($validMatricule);
|
|
|
|
// THEN
|
|
expect($employeeId->value)
|
|
->toBe('0115590')
|
|
->and((string) $employeeId)->toBe('0115590');
|
|
});
|
|
|
|
it('instantiates successfully with a valid 8-digit matricule', function (): void {
|
|
// GIVEN
|
|
$validMatricule = '01155902';
|
|
|
|
// WHEN
|
|
$employeeId = new ArcadiaEmployeeId($validMatricule);
|
|
|
|
// THEN
|
|
expect($employeeId->value)
|
|
->toBe('01155902')
|
|
->and((string) $employeeId)->toBe('01155902');
|
|
});
|
|
|
|
it('supports equality check with another ArcadiaEmployeeId instance', function (): void {
|
|
// GIVEN
|
|
$firstId = new ArcadiaEmployeeId('01155902');
|
|
$sameId = new ArcadiaEmployeeId('01155902');
|
|
$differentId = new ArcadiaEmployeeId('01155901');
|
|
|
|
// WHEN & THEN
|
|
expect($firstId->equals($sameId))
|
|
->toBeTrue()
|
|
->and($firstId->equals($differentId))
|
|
->toBeFalse();
|
|
});
|
|
|
|
it('can be converted to a string representation', function (): void {
|
|
// GIVEN
|
|
$employeeId = new ArcadiaEmployeeId('01155902');
|
|
|
|
// WHEN
|
|
$stringRepresentation = (string) $employeeId;
|
|
|
|
// THEN
|
|
expect($stringRepresentation)->toBe('01155902');
|
|
});
|
|
});
|
|
|
|
describe('ArcadiaEmployeeId Value Object Domain Rules', function (): void {
|
|
it('throws a DomainException when given an invalid matricule pattern', function (): void {
|
|
// GIVEN
|
|
$invalidMatricule = '12345';
|
|
|
|
// WHEN & THEN
|
|
expect(fn () => new ArcadiaEmployeeId($invalidMatricule))
|
|
->toThrow(\DomainException::class);
|
|
});
|
|
});
|