refactor: lit/divi-design-restore plant über RestorePlanner; PresetRestorePlanner übernimmt den bisherigen Code unverändert

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Jan-Niclas Loosen
2026-10-19 14:22:05 +02:00
co-authored by Claude Sonnet 5.5
parent 62f8465e60
commit 5af188d656
6 changed files with 242 additions and 51 deletions
@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Design;
use LIT\MCP\Integrations\Divi\Design\DesignPlan;
use LIT\MCP\Integrations\Divi\Design\DesignSystemWriter;
use LIT\MCP\Integrations\Divi\Design\PresetArea;
use LIT\MCP\Integrations\Divi\Design\PresetRestorePlanner;
use LIT\MCP\Integrations\Divi\Release\DiviFeature;
use LIT\MCP\Tests\Unit\TestCase;
use Mockery;
final class PresetRestorePlannerTest extends TestCase
{
private static function planner(bool $unfiltered = true): PresetRestorePlanner
{
return new PresetRestorePlanner(Mockery::mock(DesignSystemWriter::class), static fn (): bool => $unfiltered);
}
public function testAreaFeaturesAndDesignArea(): void
{
$planner = self::planner();
self::assertSame('presets', $planner->area());
self::assertSame([DiviFeature::DesignRead, DiviFeature::PresetWrite], $planner->features());
self::assertInstanceOf(PresetArea::class, $planner->designArea());
}
public function testPlansTheWholeSnapshotWithRemovals(): void
{
$older = PresetBookTest::stored();
unset($older['module']['divi/button']['items']['bbbbbbbbbb']);
$plan = self::planner()->plan(PresetBookTest::stored(), $older, 'presets-20261016T100000Z-aaaaaa');
self::assertInstanceOf(DesignPlan::class, $plan);
self::assertTrue($plan->mayRemove);
self::assertSame([['bbbbbbbbbb', 'removed']], array_map(
static fn (array $row): array => [$row['id'], $row['action']],
$plan->diff
));
self::assertStringStartsWith('Snapshot presets-20261016T100000Z-aaaaaa wiederherstellen – ', $plan->summary);
self::assertStringContainsString('Standard-Preset', $plan->warnings[0]);
}
public function testMarkupNeedsUnfilteredHtml(): void
{
$plan = self::planner(false)->plan(PresetBookTest::stored(), PresetBookTest::storedWithMarkup(), 'presets-1');
self::assertToolError($plan, 'forbidden');
}
}