51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Shared\ValueObjects;
|
|
|
|
use Shared\ValueObjects\Rcs;
|
|
|
|
covers(Rcs::class);
|
|
|
|
describe('Rcs text', function (): void {
|
|
it('creates a valid Rcs', function (): void {
|
|
// GIVEN
|
|
$rcsValue = 'RCS PARIS 111 222 333';
|
|
|
|
// WHEN
|
|
$rcs = new Rcs($rcsValue);
|
|
|
|
// THEN
|
|
expect($rcs)->toBeInstanceOf(Rcs::class)
|
|
->and($rcs->value)->toBe($rcsValue);
|
|
});
|
|
|
|
it('rejects an empty Rcs text', function (): void {
|
|
// GIVEN
|
|
$rcsValue = '';
|
|
|
|
// WHEN
|
|
$action = fn (): Rcs => new Rcs($rcsValue);
|
|
|
|
// THEN
|
|
expect($action)->toThrow(\DomainException::class, 'Rcs text cannot be empty.');
|
|
});
|
|
|
|
it('rejects invalid TCS text formats', function (string $invalid): void {
|
|
// GIVEN & WHEN & THEN
|
|
expect(fn (): Rcs => new Rcs($invalid))
|
|
->toThrow(\DomainException::class);
|
|
})->with([
|
|
'',
|
|
' ',
|
|
'Paris',
|
|
'RCS PARIS',
|
|
'111 222 333',
|
|
'RCS PARIS 111',
|
|
'RCS PARIS 111 222',
|
|
'PARIS 111 222 333',
|
|
'RCS PARIS 1A1 2B2 3C3',
|
|
'RCS PARIS 1111 2222 3333',
|
|
]);
|
|
});
|