feat: PresetDiff – Unterschied zweier Preset-Bestände für den Probelauf

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
Jan-Niclas Loosen
2026-10-16 17:29:51 +02:00
co-authored by Claude Haiku 5.5
parent 578ccba118
commit 388b52ea76
2 changed files with 174 additions and 0 deletions
@@ -0,0 +1,49 @@
<?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));
}
}