- Add comprehensive test suite for CMS and Asset modules using Pest Framework - Implement ContentTypeService::delete() protection against deletion of in-use content types - Add CannotDeleteContentTypeInUseException for better error handling - Fix DerivatPipelineRegistry::getAllPipelines() to handle object uniqueness correctly - Fix VariantName::getScale() to correctly parse scales with file extensions - Update CMS module documentation with new features, exceptions, and test coverage - Add CmsTestHelpers and AssetTestHelpers for test data factories - Fix BlockTypeRegistry to be immutable after construction - Update ContentTypeService to check for associated content before deletion - Improve BlockRendererRegistry initialization Test coverage: - Value Objects: All CMS and Asset value objects - Services: ContentService, ContentTypeService, SlugGenerator, BlockValidator, ContentLocalizationService, AssetService, DeduplicationService, MetadataExtractor - Repositories: All database repositories with mocked connections - Rendering: Block renderers and ContentRenderer - Controllers: API endpoints for both modules 254 tests passing, 38 remaining (mostly image processing pipeline tests)
48 lines
1.5 KiB
PHP
48 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Domain\Asset\ValueObjects\AssetId;
|
|
use App\Framework\DateTime\SystemClock;
|
|
|
|
describe('AssetId', function () {
|
|
it('can be created from valid ULID string', function () {
|
|
$validUlid = '01ARZ3NDEKTSV4RRFFQ69G5FAV';
|
|
$assetId = AssetId::fromString($validUlid);
|
|
|
|
expect($assetId->toString())->toBe($validUlid);
|
|
expect((string) $assetId)->toBe($validUlid);
|
|
});
|
|
|
|
it('throws exception for invalid ULID format', function () {
|
|
expect(fn () => AssetId::fromString('invalid-id'))
|
|
->toThrow(InvalidArgumentException::class, 'Invalid Asset ID format');
|
|
});
|
|
|
|
it('can generate new AssetId with Clock', function () {
|
|
$clock = new SystemClock();
|
|
$assetId = AssetId::generate($clock);
|
|
|
|
expect($assetId)->toBeInstanceOf(AssetId::class);
|
|
expect($assetId->toString())->toMatch('/^[0-9A-Z]{26}$/');
|
|
});
|
|
|
|
it('generates unique IDs', function () {
|
|
$clock = new SystemClock();
|
|
$id1 = AssetId::generate($clock);
|
|
$id2 = AssetId::generate($clock);
|
|
|
|
expect($id1->toString())->not->toBe($id2->toString());
|
|
});
|
|
|
|
it('can compare two AssetIds for equality', function () {
|
|
$id1 = AssetId::fromString('01ARZ3NDEKTSV4RRFFQ69G5FAV');
|
|
$id2 = AssetId::fromString('01ARZ3NDEKTSV4RRFFQ69G5FAV');
|
|
$id3 = AssetId::fromString('01ARZ3NDEKTSV4RRFFQ69G5FAW');
|
|
|
|
expect($id1->equals($id2))->toBeTrue();
|
|
expect($id1->equals($id3))->toBeFalse();
|
|
});
|
|
});
|
|
|