feat(cms,asset): add comprehensive test suite and finalize modules

- 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)
This commit is contained in:
2025-11-10 02:12:28 +01:00
parent 74d50a29cc
commit 2d53270056
53 changed files with 5699 additions and 15 deletions

View File

@@ -0,0 +1,53 @@
<?php
declare(strict_types=1);
use App\Domain\Cms\ValueObjects\ContentId;
use App\Framework\DateTime\Clock;
use App\Framework\DateTime\SystemClock;
describe('ContentId', function () {
it('can be created from valid ULID string', function () {
$validUlid = '01ARZ3NDEKTSV4RRFFQ69G5FAV';
$contentId = ContentId::fromString($validUlid);
expect($contentId->toString())->toBe($validUlid);
expect((string) $contentId)->toBe($validUlid);
});
it('throws exception for invalid ULID format', function () {
expect(fn () => ContentId::fromString('invalid-id'))
->toThrow(InvalidArgumentException::class, 'Invalid Content ID format');
});
it('throws exception for empty string', function () {
expect(fn () => ContentId::fromString(''))
->toThrow(InvalidArgumentException::class);
});
it('can generate new ContentId with Clock', function () {
$clock = new SystemClock();
$contentId = ContentId::generate($clock);
expect($contentId)->toBeInstanceOf(ContentId::class);
expect($contentId->toString())->toMatch('/^[0-9A-Z]{26}$/');
});
it('generates unique IDs', function () {
$clock = new SystemClock();
$id1 = ContentId::generate($clock);
$id2 = ContentId::generate($clock);
expect($id1->toString())->not->toBe($id2->toString());
});
it('can compare two ContentIds for equality', function () {
$id1 = ContentId::fromString('01ARZ3NDEKTSV4RRFFQ69G5FAV');
$id2 = ContentId::fromString('01ARZ3NDEKTSV4RRFFQ69G5FAV');
$id3 = ContentId::fromString('01ARZ3NDEKTSV4RRFFQ69G5FAW');
expect($id1->equals($id2))->toBeTrue();
expect($id1->equals($id3))->toBeFalse();
});
});