ldc-arcadia-api/tests/Unit/Domain/Models/ValueObjects/IncoSheets/IncoIdQueryTest.php
Jérémy Munsch 4d24e5c3fa
feat(IncoSheets): add search functionality for inco sheets
- Introduced IncoIdQuery value object for validating search queries.
- Implemented search method in IncoSheetDirectory and EloquentIncoSheetDirectory.
- Created IncoSheetsSearchController to handle search requests.
- Added IncoSheetsSearchRequest for validating incoming search parameters.
- Developed IncoSheetsSearchResponse for formatting search results.
- Added tests for search functionality in IncoSheetsSearchTest.
- Updated OpenAPI tests to validate search endpoint.
2026-08-14 15:06:54 +02:00

86 lines
2.4 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Unit\Domain\Models\ValueObjects\IncoSheets;
use Domain\Models\ValueObjects\IncoSheets\IncoIdQuery;
covers(IncoIdQuery::class);
describe('IncoIdQuery Value Object Instantiation', function (): void {
it('can be instantiated with a valid string of digits', function (): void {
// GIVEN
$validValue = '12345';
// WHEN
$incoIdQuery = new IncoIdQuery($validValue);
// THEN
expect($incoIdQuery->value)->toBe('12345');
});
it('can be instantiated with a string of digits prefixed with %', function (): void {
// GIVEN
$validValue = '%12345';
// WHEN
$incoIdQuery = new IncoIdQuery($validValue);
// THEN
expect($incoIdQuery->value)->toBe('%12345');
});
it('can be instantiated with a string of digits suffixed with %', function (): void {
// GIVEN
$validValue = '12345%';
// WHEN
$incoIdQuery = new IncoIdQuery($validValue);
// THEN
expect($incoIdQuery->value)->toBe('12345%');
});
it('can be instantiated with a string of digits prefixed and suffixed with %', function (): void {
// GIVEN
$validValue = '%12345%';
// WHEN
$incoIdQuery = new IncoIdQuery($validValue);
// THEN
expect($incoIdQuery->value)->toBe('%12345%');
});
it('can be instantiated with wildcards anywhere in the digit string', function (): void {
// GIVEN
$validValue = '%12%345%';
// WHEN
$incoIdQuery = new IncoIdQuery($validValue);
// THEN
expect($incoIdQuery->value)->toBe('%12%345%');
});
});
describe('IncoIdQuery Value Object Domain Rules', function (): void {
it('throws DomainException when instantiated with an empty string', function (): void {
// GIVEN
$invalidValue = '';
// WHEN & THEN
expect(fn () => new IncoIdQuery($invalidValue))
->toThrow(\DomainException::class, 'value cannot be empty');
});
it('throws DomainException when instantiated with a non-digit string', function (): void {
// GIVEN
$invalidValue = 'abc123';
// WHEN & THEN
expect(fn () => new IncoIdQuery($invalidValue))
->toThrow(\DomainException::class, 'value must be a string of digits optionally prefixed and/or suffixed with a % sign');
});
});