Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
32 lines
1.3 KiB
PHP
32 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Design;
|
|
|
|
use LIT\MCP\Integrations\Divi\Design\FontSignature;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class FontSignatureTest extends TestCase
|
|
{
|
|
public function testTheFourFormatsAreRecognizedByTheirFirstFourBytes(): void
|
|
{
|
|
self::assertSame('woff2', FontSignature::detect("wOF2\x00\x01\x00\x00\x00\x00\x12\x34"));
|
|
self::assertSame('woff', FontSignature::detect("wOFF\x00\x01\x00\x00"));
|
|
self::assertSame('ttf', FontSignature::detect("\x00\x01\x00\x00\x00\x0c\x00\x80"));
|
|
self::assertSame('ttf', FontSignature::detect('true' . "\x00\x0c"), 'Apple TrueType');
|
|
self::assertSame('otf', FontSignature::detect("OTTO\x00\x0a\x00\x80"));
|
|
}
|
|
|
|
public function testEverythingElseIsNoFont(): void
|
|
{
|
|
self::assertNull(FontSignature::detect(''));
|
|
self::assertNull(FontSignature::detect('wOF'), 'too short');
|
|
self::assertNull(FontSignature::detect('wof2'), 'case matters');
|
|
self::assertNull(FontSignature::detect('ttcf'), 'font collections are not accepted');
|
|
self::assertNull(FontSignature::detect("\x89PNG\r\n\x1a\n"));
|
|
self::assertNull(FontSignature::detect('<?php evil();'));
|
|
self::assertNull(FontSignature::detect("\x00wOF2"), 'the magic must start at byte 0');
|
|
}
|
|
}
|