fix: SnapshotStore verweigert nicht kodierbare Snapshots
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 5.5
parent
5ba52b98b3
commit
6ee8f9258a
@@ -87,6 +87,25 @@ final class SnapshotStoreTest extends TestCase
|
||||
(new SnapshotStore())->save('presets', ['a' => 1], 'lit/divi-presets-set');
|
||||
}
|
||||
|
||||
public function testAnUnencodableSnapshotIsRefusedBeforeAnyWrite(): void
|
||||
{
|
||||
Functions\when('wp_json_encode')->justReturn(false);
|
||||
$written = false;
|
||||
Functions\when('update_option')->alias(function () use (&$written): bool {
|
||||
$written = true;
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
try {
|
||||
(new SnapshotStore())->save('presets', ['a' => 1], 'lit/divi-presets-set');
|
||||
self::fail('an unencodable snapshot must be refused');
|
||||
} catch (RuntimeException $e) {
|
||||
self::assertSame('snapshot presets could not be encoded', $e->getMessage());
|
||||
}
|
||||
self::assertFalse($written, 'nothing may be written when the snapshot cannot be encoded');
|
||||
}
|
||||
|
||||
public function testCorruptOptionReadsAsEmpty(): void
|
||||
{
|
||||
$this->options['lit_mcp_snapshots_presets'] = 'kaputt';
|
||||
|
||||
Reference in New Issue
Block a user