Files
WP-LIT-MCP/tests/Unit/Integrations/Divi/Compose/WarningsTest.php
T
janniclas.loosenandClaude Opus 5.5 3d96a41366 test: shared Divi fixtures in tests/Support (T1)
- DiviFixtures: markup(), givenPost(), schema(), designSystem(), catalog(),
  dynamicContentRegistry(), maliciousRefs() - moved verbatim out of
  DiviPageLoaderTest, DesignSystemTest, ModuleCatalogTest, DynamicContentMapTest
  and VariableRefTest (its malicious() provider now returns maliciousRefs()).
- ComposeFixture moves to tests/Support.
- DiviWriterFixture: modules(), designReader(), composition(), a recording saver(),
  log() and writer(&$saved, &$failures, unfiltered, loader) for the five tests that
  wired the Divi write stack by hand.
No test cases or assertions changed (1397 / 5834).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 17:47:11 +02:00

57 lines
2.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Compose;
use LIT\MCP\Integrations\Divi\BlockTree\Document;
use LIT\MCP\Integrations\Divi\BlockTree\NodeIndex;
use LIT\MCP\Integrations\Divi\Compose\Warnings;
use LIT\MCP\Tests\Support\ComposeFixture;
use LIT\MCP\Tests\Support\DiviFixtures;
use PHPUnit\Framework\TestCase;
final class WarningsTest extends TestCase
{
public function testWarnsAboutTheTouchedNodesOnly(): void
{
$composed = ComposeFixture::composer()->compose([
['type' => 'section', 'label' => 'Test', 'modules' => [
['type' => 'heading', 'text' => 'Titel', 'level' => 'h1'],
['type' => 'heading', 'text' => 'Zu tief', 'level' => 'h4'],
['type' => 'image', 'src' => 'https://kunde.test/a.jpg'],
['type' => 'text', 'content' => ''],
['type' => 'code', 'content' => '<div>x</div>'],
['type' => 'accordion'],
['type' => 'button', 'text' => 'Los', 'attrs' => [
'button.decoration.background' => ['desktop' => ['color' => '#2ea3f3']],
'button.decoration.font.font' => ['desktop' => ['family' => 'Open Sans', 'color' => '#abcdef']],
]],
]],
], null, 'nodes');
self::assertSame([], $composed['errors']);
$document = new Document();
foreach ($composed['blocks'] as $block) {
$document->append($block);
}
$warnings = (new Warnings(DiviFixtures::designSystem()))->collect(NodeIndex::build($document), $composed['blocks']);
self::assertSame(
[
's0.r0.c0.m2: Bild ohne Alt-Text.',
's0.r0.c0.m3: text ist leer (content fehlt).',
's0.r0.c0.m4: Code-Modul verwendet – im Divi-Builder nicht visuell bearbeitbar; nur nutzen, wenn kein '
. 'natives Modul passt.',
's0.r0.c0.m5: accordion ohne Einträge.',
's0.r0.c0.m6: feste Farbe #2ea3f3 – globale Farbe "Primärfarbe" ({{color:primary}}) passt.',
's0.r0.c0.m6: feste Schrift Open Sans – {{font:heading}} verwenden.',
's0.r0.c0.m1: Sprung in der Überschriftenhierarchie (h4 nach h1).',
],
$warnings
);
self::assertSame([], (new Warnings(DiviFixtures::designSystem()))->collect(NodeIndex::build($document), []));
}
}