Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
50 lines
2.0 KiB
PHP
50 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Design;
|
|
|
|
use LIT\MCP\Integrations\Divi\Design\PresetBook;
|
|
use LIT\MCP\Integrations\Divi\Design\PresetDiff;
|
|
use LIT\MCP\Integrations\Divi\Design\PresetScope;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class PresetDiffTest extends TestCase
|
|
{
|
|
public function testNoChangeIsAnEmptyDiff(): void
|
|
{
|
|
$book = PresetBook::fromDivi(PresetBookTest::stored());
|
|
|
|
self::assertSame([], PresetDiff::between($book, PresetBook::fromDivi(PresetBookTest::stored())));
|
|
}
|
|
|
|
public function testAddedChangedRemovedAndDefaults(): void
|
|
{
|
|
$before = PresetBook::fromDivi(PresetBookTest::stored());
|
|
$button = new PresetScope('module', 'divi/button');
|
|
$text = new PresetScope('module', 'divi/text');
|
|
$changed = $before->items($button)['aaaaaaaaaa'];
|
|
$changed['attrs'] = ['button' => ['x' => 2]];
|
|
$changed['updated'] = 99;
|
|
$changed['styleAttrs'] = ['ignored' => true];
|
|
$after = $before
|
|
->with($button, $changed)
|
|
->with($button, ['id' => 'eeeeeeeeee', 'name' => 'Neu', 'attrs' => []])
|
|
->withDefault($button, 'eeeeeeeeee')
|
|
->without($button, 'bbbbbbbbbb')
|
|
->withDefault($text, '');
|
|
|
|
self::assertSame([
|
|
['kind' => 'module', 'scope' => 'divi/button', 'id' => 'aaaaaaaaaa', 'name' => 'CTA primär',
|
|
'action' => 'changed', 'fields' => ['attrs']],
|
|
['kind' => 'module', 'scope' => 'divi/button', 'id' => 'bbbbbbbbbb', 'name' => 'Doppelt',
|
|
'action' => 'removed'],
|
|
['kind' => 'module', 'scope' => 'divi/button', 'id' => 'eeeeeeeeee', 'name' => 'Neu', 'action' => 'added'],
|
|
['kind' => 'module', 'scope' => 'divi/button', 'id' => 'eeeeeeeeee', 'name' => 'Neu',
|
|
'action' => 'default_set'],
|
|
['kind' => 'module', 'scope' => 'divi/text', 'id' => 'dddddddddd', 'name' => 'Fließtext',
|
|
'action' => 'default_cleared'],
|
|
], PresetDiff::between($before, $after));
|
|
}
|
|
}
|