refactor: ein Helfer für Gruppen-Kurznamen (NodeSummary::groupShortName), ESCAPED_LETTER_REGEX am UsageQuery-Interface, Docblock DiviComposition::presets; Tests für Muster, Kurzname und Gruppen-Überdeckung

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Jan-Niclas Loosen
2026-10-18 17:40:21 +02:00
co-authored by Claude Sonnet 5.5
parent 6d7c59e3fa
commit e7793fd595
13 changed files with 70 additions and 16 deletions
@@ -64,4 +64,11 @@ final class NodeSummaryTest extends TestCase
self::assertSame([], NodeSummary::groupPresets(Block::create('divi/text', ['groupPreset' => 'x'])));
self::assertSame([], NodeSummary::groupPresets(Block::create('divi/text', ['groupPreset' => []])));
}
public function testGroupShortNameDropsTheDiviPrefixOnly(): void
{
self::assertSame('font-body', NodeSummary::groupShortName('divi/font-body'));
self::assertSame('custom/x', NodeSummary::groupShortName('custom/x'));
self::assertSame('spacing', NodeSummary::groupShortName('spacing'));
}
}
@@ -132,6 +132,35 @@ final class WarningsTest extends TestCase
self::assertStringEndsWith('clear_overrides: true entfernt sie.', $covering[0]);
}
/** A group preset only triggered loading before: its values are overridden by local ones like a module preset's. */
public function testWarnsWhenLocalValuesCoverAGroupPreset(): void
{
$path = 'button.decoration.font.font';
$book = PresetBook::fromDivi(['group' => ['divi/font' => ['default' => '', 'items' => [
'g-1' => [
'type' => 'group', 'id' => 'g-1', 'name' => 'Fließtext groß', 'groupName' => 'divi/font',
'groupId' => $path, 'moduleName' => 'divi/button',
'attrs' => ['button' => ['decoration' => ['font' => ['font' => [
'desktop' => ['value' => ['color' => '#ffffff']],
]]]]],
],
]]]]);
$presets = ComposeFixture::presetAssignment(null, null, null, null, static fn (): PresetBook => $book);
$button = Block::create('divi/button', [
'groupPreset' => [$path => ['presetId' => ['g-1'], 'groupName' => 'divi/font']],
'button' => ['decoration' => ['font' => ['font' => ['desktop' => ['value' => ['color' => '#000000']]]]]],
]);
[$covering, $index] = self::collect([$button], [$button], $presets);
self::assertCount(1, $covering);
self::assertStringStartsWith(
$index->idOf($button) . ': lokale Werte überdecken „Fließtext groß“: ',
$covering[0]
);
self::assertStringContainsString($path, $covering[0]);
}
public function testEqualValuesAndUntouchedBlocksDoNotWarn(): void
{
$loads = 0;
@@ -4,12 +4,23 @@ declare(strict_types=1);
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Library;
use LIT\MCP\Integrations\Divi\Design\ModuleUsageQuery;
use LIT\MCP\Integrations\Divi\Design\PresetUsageQuery;
use LIT\MCP\Integrations\Divi\Library\LibraryUsageQuery;
use LIT\MCP\Integrations\Divi\Library\UsageQuery;
use LIT\MCP\Tests\Unit\TestCase;
use Mockery;
final class LibraryUsageQueryTest extends TestCase
{
/** The one fail-closed pattern for JSON-escaped letters (two backslashes, "u00", a letter range). */
public function testEscapedLetterPatternIsPinned(): void
{
self::assertSame(str_repeat(chr(92), 2) . 'u00[4-7][0-9a-fA-F]', UsageQuery::ESCAPED_LETTER_REGEX);
self::assertSame(UsageQuery::ESCAPED_LETTER_REGEX, ModuleUsageQuery::ESCAPED_LETTER_REGEX);
self::assertSame(UsageQuery::ESCAPED_LETTER_REGEX, PresetUsageQuery::ESCAPED_LETTER_REGEX);
}
public function testConditionIsTheFormerCandidateFilter(): void
{
$db = Mockery::mock(\wpdb::class);