Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
68 lines
2.6 KiB
PHP
68 lines
2.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace LIT\MCP\Tests\Unit\Integrations\Divi\BlockTree;
|
|
|
|
use LIT\MCP\Integrations\Divi\BlockTree\Block;
|
|
use LIT\MCP\Integrations\Divi\BlockTree\NodeSummary;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class NodeSummaryTest extends TestCase
|
|
{
|
|
public function testGroupPresetsByGroupId(): void
|
|
{
|
|
$block = Block::create('divi/blurb', ['groupPreset' => [
|
|
'content.decoration.bodyFont' => ['presetId' => ['ja6o54jtlc'], 'groupName' => 'divi/font-body'],
|
|
'module.decoration.spacing' => ['presetId' => ['apzj7e17ok', 'b2b2b2b2b2'], 'groupName' => 'divi/spacing'],
|
|
]]);
|
|
|
|
self::assertSame(
|
|
[
|
|
'content.decoration.bodyFont' => ['groupName' => 'divi/font-body', 'presetIds' => ['ja6o54jtlc']],
|
|
'module.decoration.spacing' => [
|
|
'groupName' => 'divi/spacing',
|
|
'presetIds' => ['apzj7e17ok', 'b2b2b2b2b2'],
|
|
],
|
|
],
|
|
NodeSummary::groupPresets($block)
|
|
);
|
|
}
|
|
|
|
public function testPresetIdAsStringIsAccepted(): void
|
|
{
|
|
$block = Block::create('divi/text', ['groupPreset' => [
|
|
'content.decoration.bodyFont' => ['presetId' => 'ja6o54jtlc', 'groupName' => 'divi/font-body'],
|
|
]]);
|
|
|
|
self::assertSame(
|
|
['content.decoration.bodyFont' => ['groupName' => 'divi/font-body', 'presetIds' => ['ja6o54jtlc']]],
|
|
NodeSummary::groupPresets($block)
|
|
);
|
|
}
|
|
|
|
public function testEmptyIdsAreFilteredAndBrokenEntriesLeftOut(): void
|
|
{
|
|
$block = Block::create('divi/text', ['groupPreset' => [
|
|
'a.one' => ['presetId' => ['', 'x1', 7, null], 'groupName' => 'divi/font'],
|
|
'a.two' => ['presetId' => [''], 'groupName' => 'divi/font'],
|
|
'a.three' => ['presetId' => ['x2']],
|
|
'a.four' => ['presetId' => ['x3'], 'groupName' => ''],
|
|
'a.five' => ['presetId' => ['x4'], 'groupName' => ['divi/font']],
|
|
'a.six' => 'kein Eintrag',
|
|
]]);
|
|
|
|
self::assertSame(
|
|
['a.one' => ['groupName' => 'divi/font', 'presetIds' => ['x1']]],
|
|
NodeSummary::groupPresets($block)
|
|
);
|
|
}
|
|
|
|
public function testBlockWithoutOrWithBrokenGroupPreset(): void
|
|
{
|
|
self::assertSame([], NodeSummary::groupPresets(Block::create('divi/text')));
|
|
self::assertSame([], NodeSummary::groupPresets(Block::create('divi/text', ['groupPreset' => 'x'])));
|
|
self::assertSame([], NodeSummary::groupPresets(Block::create('divi/text', ['groupPreset' => []])));
|
|
}
|
|
}
|