feat: lit/divi-design-snapshots und lit/divi-design-restore (Bereich presets)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Jan-Niclas Loosen
2026-10-16 17:52:20 +02:00
co-authored by Claude Sonnet 5.5
parent 2e8f723b01
commit 327f8d2d35
6 changed files with 322 additions and 0 deletions
@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Design;
use Brain\Monkey\Functions;
use LIT\MCP\Integrations\Divi\Design\DiviDesignSnapshotsAbility;
use LIT\MCP\Integrations\Divi\Design\SnapshotStore;
use LIT\MCP\Tests\Unit\TestCase;
use Mockery;
final class DiviDesignSnapshotsAbilityTest extends TestCase
{
public function testListsTheSnapshotsOfAnArea(): void
{
Functions\when('current_user_can')->alias(static fn (string $cap): bool => $cap === 'edit_theme_options');
$store = Mockery::mock(SnapshotStore::class);
$store->expects('list')->with('presets')->andReturn([
['id' => 'presets-2', 'created' => '2026-10-16T10:00:00+00:00', 'user_id' => 1,
'ability' => 'lit/divi-presets-set', 'log_id' => 4, 'size' => 120],
]);
$ability = new DiviDesignSnapshotsAbility($store);
self::assertTrue($ability->permission([]));
$result = $ability->execute([]);
self::assertSame('presets', $result['area']);
self::assertSame('presets-2', $result['snapshots'][0]['id']);
self::assertTrue($ability->annotations()['readonly']);
}
public function testUnknownAreaAndRights(): void
{
Functions\when('current_user_can')->justReturn(false);
$ability = new DiviDesignSnapshotsAbility(Mockery::mock(SnapshotStore::class));
self::assertToolError($ability->permission([]), 'forbidden');
Functions\when('current_user_can')->justReturn(true);
self::assertToolError($ability->execute(['area' => 'seiten']), 'validation_failed');
}
}