ldc-arcadia-api/tests/Unit/Domain/Models/ValueObjects/Entities/ArcadiaEmployeeIdTest.php

69 lines
1.9 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace Tests\Unit\Domain;
use Domain\Models\ValueObjects\Entities\ArcadiaEmployeeId;
describe('ArcadiaEmployeeId Value Object', 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');
});
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);
});
});