feat: implement preview manager
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -6,7 +6,6 @@ namespace KTXT\Unit\Preview;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use KTXC\Models\Tenant\TenantConfiguration;
|
||||
use KTXC\Models\Tenant\TenantPreviewGeneration;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -19,10 +18,7 @@ final class PreviewConfigurationTest extends TestCase
|
||||
|
||||
self::assertTrue($preview->enabled());
|
||||
self::assertSame('previews', $preview->store());
|
||||
self::assertSame(TenantPreviewGeneration::MODE_EAGER_WITH_LAZY_FALLBACK, $preview->generation()->mode());
|
||||
self::assertSame(104857600, $preview->generation()->maxSourceSize());
|
||||
self::assertSame(30, $preview->generation()->timeoutSeconds());
|
||||
self::assertSame(3600, $preview->generation()->retryDelaySeconds());
|
||||
self::assertSame(26214400, $preview->maxSourceSize());
|
||||
self::assertSame(640, $preview->variants()->variant('popover')?->width);
|
||||
self::assertSame(440, $preview->variants()->variant('popover')?->height);
|
||||
self::assertSame('image/webp', $preview->variants()->variant('popover')?->format);
|
||||
@@ -36,12 +32,7 @@ final class PreviewConfigurationTest extends TestCase
|
||||
$data = [
|
||||
'enabled' => true,
|
||||
'store' => 'generated-content',
|
||||
'generation' => [
|
||||
'mode' => TenantPreviewGeneration::MODE_LAZY,
|
||||
'maxSourceSize' => 1024,
|
||||
'timeoutSeconds' => 5,
|
||||
'retryDelaySeconds' => 60,
|
||||
],
|
||||
'maxSourceSize' => 1024,
|
||||
'variants' => [
|
||||
'popover' => [
|
||||
'width' => 800,
|
||||
@@ -55,7 +46,7 @@ final class PreviewConfigurationTest extends TestCase
|
||||
$configuration = (new TenantConfiguration())->jsonDeserialize(['preview' => $data]);
|
||||
|
||||
self::assertSame('generated-content', $configuration->preview()->store());
|
||||
self::assertSame(TenantPreviewGeneration::MODE_LAZY, $configuration->preview()->generation()->mode());
|
||||
self::assertSame(1024, $configuration->preview()->maxSourceSize());
|
||||
self::assertSame(['popover'], array_keys($configuration->preview()->variants()->all()));
|
||||
self::assertSame('image/png', $configuration->preview()->variants()->variant('popover')?->format);
|
||||
$data['variants']['popover']['format'] = 'image/png';
|
||||
@@ -96,8 +87,7 @@ final class PreviewConfigurationTest extends TestCase
|
||||
public static function invalidConfigurations(): iterable
|
||||
{
|
||||
yield 'invalid store' => [['store' => '../previews']];
|
||||
yield 'unknown generation mode' => [['generation' => ['mode' => 'eager']]];
|
||||
yield 'zero source limit' => [['generation' => ['maxSourceSize' => 0]]];
|
||||
yield 'zero source limit' => [['maxSourceSize' => 0]];
|
||||
yield 'invalid variant name' => [['variants' => ['../popover' => []]]];
|
||||
yield 'invalid dimensions' => [['variants' => ['popover' => ['width' => 0]]]];
|
||||
yield 'invalid output MIME' => [['variants' => ['popover' => ['format' => 'webp']]]];
|
||||
|
||||
Reference in New Issue
Block a user