feat: lit/divi-theme-options-update ändert Theme-Optionen über DesignChange (Prüfung, Divi-Sanitizer, Schriftvorschläge)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
122548db12
commit
879ca752e7
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Design;
|
||||
|
||||
use LIT\MCP\Integrations\Divi\Design\FontCatalog;
|
||||
use LIT\MCP\Integrations\Divi\Design\FontCheck;
|
||||
use LIT\MCP\Integrations\Divi\Design\FontSuggest;
|
||||
use LIT\MCP\Tests\Unit\TestCase;
|
||||
use Mockery;
|
||||
use Mockery\MockInterface;
|
||||
|
||||
final class FontCheckTest extends TestCase
|
||||
{
|
||||
/** The names FontCatalog::names() delivers in these tests. */
|
||||
public const NAMES = ['Lato', 'Open Sans', 'Roboto', 'Roboto Mono', 'Roboto Slab'];
|
||||
|
||||
/** A FontCatalog over NAMES: has() is exact, like Divi's sanitizer (ruling W5). */
|
||||
public static function catalog(): FontCatalog&MockInterface
|
||||
{
|
||||
$fonts = Mockery::mock(FontCatalog::class);
|
||||
$fonts->allows('names')->andReturn(self::NAMES);
|
||||
$fonts->allows('has')->andReturnUsing(static fn (string $name): bool => in_array($name, self::NAMES, true));
|
||||
|
||||
return $fonts;
|
||||
}
|
||||
|
||||
public function testAKnownFontIsFine(): void
|
||||
{
|
||||
$fonts = self::catalog();
|
||||
$fonts->shouldNotReceive('names');
|
||||
|
||||
self::assertNull(FontCheck::problem($fonts, 'Roboto Mono'));
|
||||
}
|
||||
|
||||
/** Ruling W5: the name is exact – "roboto" is unknown, but gets "Roboto" as suggestion. */
|
||||
public function testAnUnknownFontGetsSimilarNames(): void
|
||||
{
|
||||
self::assertSame(
|
||||
sprintf(
|
||||
'unbekannte Schrift „roboto“; ähnlich: %s',
|
||||
implode(', ', FontSuggest::similar('roboto', self::NAMES))
|
||||
),
|
||||
FontCheck::problem(self::catalog(), 'roboto')
|
||||
);
|
||||
self::assertStringContainsString('Roboto', (string) FontCheck::problem(self::catalog(), 'roboto'));
|
||||
}
|
||||
|
||||
public function testWithoutSimilarNamesTheUploadToolIsNamed(): void
|
||||
{
|
||||
self::assertSame(
|
||||
'unbekannte Schrift „Xyzzy Grotesk“; eigene Schriften lädt lit/divi-fonts-upload hoch',
|
||||
FontCheck::problem(self::catalog(), 'Xyzzy Grotesk')
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user