Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
51 lines
1.8 KiB
PHP
51 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Release;
|
|
|
|
use LIT\MCP\Integrations\Divi\BlockTree\Block;
|
|
use LIT\MCP\Integrations\Divi\BlockTree\Parser;
|
|
use LIT\MCP\Integrations\Divi\Release\FormatCheck;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class FormatCheckTest extends TestCase
|
|
{
|
|
/** parse_blocks() as WordPress would answer for well-formed Divi markup: the same names and nesting. */
|
|
private static function wordPress(): \Closure
|
|
{
|
|
$convert = static function (array $blocks) use (&$convert): array {
|
|
return array_map(static fn (Block $block): array => [
|
|
'blockName' => $block->name(),
|
|
'innerBlocks' => $convert($block->children()),
|
|
], $blocks);
|
|
};
|
|
|
|
return static fn (string $content): array => $convert((new Parser())->parse($content)->children());
|
|
}
|
|
|
|
public function testTheShippedReferenceRoundTripsAndMatchesWordPress(): void
|
|
{
|
|
self::assertSame([], (new FormatCheck(null, self::wordPress()))->problems());
|
|
self::assertFileEquals(
|
|
dirname(__DIR__, 5) . '/tests/Fixtures/divi/converted-landing.html',
|
|
FormatCheck::REFERENCE
|
|
);
|
|
}
|
|
|
|
public function testADifferentStructureInWordPressIsReported(): void
|
|
{
|
|
$check = new FormatCheck(null, static fn (): array => [['blockName' => 'divi/section', 'innerBlocks' => []]]);
|
|
|
|
self::assertSame(['WordPress liest eine andere Blockstruktur als LIT MCP.'], $check->problems());
|
|
}
|
|
|
|
public function testAMissingReferenceIsReported(): void
|
|
{
|
|
self::assertSame(
|
|
['Der Referenzinhalt der Prüfung fehlt im Plugin.'],
|
|
(new FormatCheck('/nonexistent/reference.html', self::wordPress()))->problems()
|
|
);
|
|
}
|
|
}
|