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:
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Domain\Asset\Entities\Asset;
|
||||
use App\Domain\Asset\Pipeline\DerivatPipelineInterface;
|
||||
use App\Domain\Asset\Pipeline\DerivatPipelineRegistry;
|
||||
use App\Domain\Asset\Pipeline\ImageDerivatPipeline;
|
||||
use App\Domain\Asset\ValueObjects\AssetId;
|
||||
use App\Domain\Asset\ValueObjects\AssetMetadata;
|
||||
use App\Framework\Core\ValueObjects\FileSize;
|
||||
use App\Framework\Core\ValueObjects\Hash;
|
||||
use App\Framework\Core\ValueObjects\HashAlgorithm;
|
||||
use App\Framework\Core\ValueObjects\Timestamp;
|
||||
use App\Framework\DateTime\SystemClock;
|
||||
use App\Framework\Http\MimeType;
|
||||
use App\Framework\Storage\ValueObjects\BucketName;
|
||||
use App\Framework\Storage\ValueObjects\ObjectKey;
|
||||
use Tests\Support\AssetTestHelpers;
|
||||
|
||||
describe('DerivatPipelineRegistry', function () {
|
||||
it('registers pipeline for supported formats', function () {
|
||||
$registry = new DerivatPipelineRegistry();
|
||||
$pipeline = new ImageDerivatPipeline(BucketName::fromString('variants'));
|
||||
|
||||
$registry->register($pipeline);
|
||||
|
||||
$asset = AssetTestHelpers::createAsset($this->clock, mime: MimeType::IMAGE_JPEG);
|
||||
$found = $registry->getPipelineForAsset($asset);
|
||||
|
||||
expect($found)->toBe($pipeline);
|
||||
});
|
||||
|
||||
it('returns null for unsupported format', function () {
|
||||
$registry = new DerivatPipelineRegistry();
|
||||
$pipeline = new ImageDerivatPipeline(BucketName::fromString('variants'));
|
||||
|
||||
$registry->register($pipeline);
|
||||
|
||||
$asset = AssetTestHelpers::createAsset($this->clock, mime: MimeType::VIDEO_MP4);
|
||||
$found = $registry->getPipelineForAsset($asset);
|
||||
|
||||
expect($found)->toBeNull();
|
||||
});
|
||||
|
||||
it('can register multiple pipelines', function () {
|
||||
$registry = new DerivatPipelineRegistry();
|
||||
$imagePipeline = new ImageDerivatPipeline(BucketName::fromString('variants'));
|
||||
|
||||
$registry->register($imagePipeline);
|
||||
|
||||
$all = $registry->getAllPipelines();
|
||||
|
||||
expect($all)->toContain($imagePipeline);
|
||||
});
|
||||
|
||||
it('overwrites pipeline when same format is registered twice', function () {
|
||||
$registry = new DerivatPipelineRegistry();
|
||||
$pipeline1 = new ImageDerivatPipeline(BucketName::fromString('variants'));
|
||||
$pipeline2 = new ImageDerivatPipeline(BucketName::fromString('custom-variants'));
|
||||
|
||||
$registry->register($pipeline1);
|
||||
$registry->register($pipeline2);
|
||||
|
||||
$asset = AssetTestHelpers::createAsset($this->clock, mime: MimeType::IMAGE_JPEG);
|
||||
$found = $registry->getPipelineForAsset($asset);
|
||||
|
||||
expect($found)->toBe($pipeline2);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user