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:
co-authored by
Claude Sonnet 5.5
parent
62f8465e60
commit
5af188d656
@@ -8,6 +8,7 @@ use Brain\Monkey\Functions;
|
||||
use LIT\MCP\Integrations\Divi\Design\DesignChange;
|
||||
use LIT\MCP\Integrations\Divi\Design\DesignSystemWriter;
|
||||
use LIT\MCP\Integrations\Divi\Design\DiviDesignRestoreAbility;
|
||||
use LIT\MCP\Integrations\Divi\Design\PresetRestorePlanner;
|
||||
use LIT\MCP\Integrations\Divi\Design\SnapshotStore;
|
||||
use LIT\MCP\Tests\Support\FakeChangeLog;
|
||||
use LIT\MCP\Tests\Unit\TestCase;
|
||||
@@ -37,7 +38,11 @@ final class DiviDesignRestoreAbilityTest extends TestCase
|
||||
'created' => 'x', 'user_id' => 1, 'ability' => 'lit/divi-presets-set', 'log_id' => 2, 'size' => 1]);
|
||||
$snapshots->expects('save')->with('presets', Mockery::type('array'), 'lit/divi-design-restore')->andReturn('presets-3');
|
||||
$snapshots->expects('attachLog');
|
||||
$ability = new DiviDesignRestoreAbility($writer, new DesignChange($snapshots, new FakeChangeLog(8)), $snapshots);
|
||||
$ability = new DiviDesignRestoreAbility(
|
||||
new DesignChange($snapshots, new FakeChangeLog(8)),
|
||||
$snapshots,
|
||||
new PresetRestorePlanner($writer)
|
||||
);
|
||||
|
||||
$dry = self::assertToolError($ability->execute(['snapshot_id' => 'presets-20261016T100000Z-aaaaaa']), 'confirm_required');
|
||||
self::assertSame('removed', $dry['diff'][0]['action']);
|
||||
@@ -63,10 +68,9 @@ final class DiviDesignRestoreAbilityTest extends TestCase
|
||||
$snapshots->shouldNotReceive('save');
|
||||
|
||||
return new DiviDesignRestoreAbility(
|
||||
$writer,
|
||||
new DesignChange($snapshots, FakeChangeLog::forbidden()),
|
||||
$snapshots,
|
||||
static fn (): bool => $unfiltered
|
||||
new PresetRestorePlanner($writer, static fn (): bool => $unfiltered)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -96,7 +100,11 @@ final class DiviDesignRestoreAbilityTest extends TestCase
|
||||
$writer->shouldNotReceive('savePresets');
|
||||
$snapshots = Mockery::mock(SnapshotStore::class);
|
||||
$snapshots->shouldNotReceive('get');
|
||||
$ability = new DiviDesignRestoreAbility($writer, new DesignChange($snapshots, FakeChangeLog::forbidden()), $snapshots);
|
||||
$ability = new DiviDesignRestoreAbility(
|
||||
new DesignChange($snapshots, FakeChangeLog::forbidden()),
|
||||
$snapshots,
|
||||
new PresetRestorePlanner($writer)
|
||||
);
|
||||
$input = ['snapshot_id' => 'presets-20261016T100000Z-aaaaaa', 'confirm' => true, 'design_rev' => 'x'];
|
||||
|
||||
self::assertToolError($ability->permission($input), 'forbidden');
|
||||
@@ -110,7 +118,11 @@ final class DiviDesignRestoreAbilityTest extends TestCase
|
||||
$writer->allows('canUseVisualBuilder')->andReturn(true);
|
||||
$snapshots = Mockery::mock(SnapshotStore::class);
|
||||
$snapshots->allows('get')->andReturn(null);
|
||||
$ability = new DiviDesignRestoreAbility($writer, new DesignChange($snapshots, FakeChangeLog::forbidden()), $snapshots);
|
||||
$ability = new DiviDesignRestoreAbility(
|
||||
new DesignChange($snapshots, FakeChangeLog::forbidden()),
|
||||
$snapshots,
|
||||
new PresetRestorePlanner($writer)
|
||||
);
|
||||
|
||||
self::assertToolError($ability->execute(['snapshot_id' => 'presets-20261016T100000Z-abcdef']), 'not_found');
|
||||
self::assertToolError($ability->execute(['snapshot_id' => 'colors-20261016T100000Z-abcdef']), 'unsupported');
|
||||
|
||||
Reference in New Issue
Block a user