57 lines
1.4 KiB
PHP
57 lines
1.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace Tests\Unit\Application\Security\ValueObjects;
|
||
|
|
|
||
|
|
use Application\Security\Models\ValueObjects\ClientName;
|
||
|
|
|
||
|
|
covers(ClientName::class);
|
||
|
|
|
||
|
|
describe('ClientName Value Object Instantiation', function (): void {
|
||
|
|
it('accepts valid client names', function (string $input): void {
|
||
|
|
// GIVEN
|
||
|
|
$value = $input;
|
||
|
|
|
||
|
|
// WHEN
|
||
|
|
$clientName = new ClientName($value);
|
||
|
|
|
||
|
|
// THEN
|
||
|
|
expect($clientName->value)->toBe($value);
|
||
|
|
})->with([
|
||
|
|
'Arcadia Test Client',
|
||
|
|
'A',
|
||
|
|
str_repeat('b', 255),
|
||
|
|
]);
|
||
|
|
});
|
||
|
|
|
||
|
|
describe('ClientName Value Object Validation Rules', function (): void {
|
||
|
|
it('throws InvalidArgumentException when given an empty client name', function (): void {
|
||
|
|
// GIVEN
|
||
|
|
$invalid = '';
|
||
|
|
|
||
|
|
// WHEN
|
||
|
|
$execution = fn () => new ClientName($invalid);
|
||
|
|
|
||
|
|
// THEN
|
||
|
|
expect($execution)->toThrow(
|
||
|
|
\InvalidArgumentException::class,
|
||
|
|
'ClientName cannot be empty.'
|
||
|
|
);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('throws InvalidArgumentException when client name exceeds 255 characters', function (): void {
|
||
|
|
// GIVEN
|
||
|
|
$invalid = str_repeat('a', 256);
|
||
|
|
|
||
|
|
// WHEN
|
||
|
|
$execution = fn () => new ClientName($invalid);
|
||
|
|
|
||
|
|
// THEN
|
||
|
|
expect($execution)->toThrow(
|
||
|
|
\InvalidArgumentException::class,
|
||
|
|
'ClientName cannot exceed 255 characters.'
|
||
|
|
);
|
||
|
|
});
|
||
|
|
});
|