fix: lit/divi-colors-set und lit/divi-variables-set lehnen unbekannte Item-Felder ab (delete, Tippfehler)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
bb2377991d
commit
02ed5bdbd3
@@ -276,6 +276,23 @@ final class DiviColorsSetAbilityTest extends TestCase
|
||||
self::assertSame([], $this->saves);
|
||||
}
|
||||
|
||||
public function testUnknownItemKeysAreRefusedAndCollectedWithOtherErrors(): void
|
||||
{
|
||||
$error = $this->ability()->execute(['items' => [
|
||||
['id' => 'gcid-holz000001', 'delete' => true],
|
||||
['id' => 'gcid-holz000001', 'stauts' => 'inactive'],
|
||||
['id' => 'Fehlt', 'color' => '#ffffff'],
|
||||
]]);
|
||||
|
||||
self::assertToolError($error, 'validation_failed');
|
||||
$fields = self::errorFields($error);
|
||||
self::assertSame(['items[0].delete', 'items[1].stauts', 'items[2].id'], array_keys($fields));
|
||||
self::assertStringContainsString('inactive', $fields['items[0].delete']);
|
||||
self::assertSame('unbekanntes Feld', $fields['items[1].stauts']);
|
||||
self::assertSame([], $this->saves);
|
||||
self::assertFalse($this->ability()->inputSchema()['properties']['items']['items']['additionalProperties']);
|
||||
}
|
||||
|
||||
public function testAFailedWriteIsRolledBack(): void
|
||||
{
|
||||
$calls = [];
|
||||
|
||||
@@ -275,6 +275,24 @@ final class DiviVariablesSetAbilityTest extends TestCase
|
||||
self::assertSame([], $this->saves);
|
||||
}
|
||||
|
||||
/** Ruling V1: "delete" (or a typo) must not look like a successful no-op. */
|
||||
public function testUnknownItemKeysAreRefusedAndCollectedWithOtherErrors(): void
|
||||
{
|
||||
$error = $this->ability()->execute(['items' => [
|
||||
['id' => 'Slogan', 'delete' => true],
|
||||
['id' => 'Slogan', 'stauts' => 'archived'],
|
||||
['id' => 'Fehlt', 'value' => '1px'],
|
||||
]]);
|
||||
|
||||
self::assertToolError($error, 'validation_failed');
|
||||
$fields = self::errorFields($error);
|
||||
self::assertSame(['items[0].delete', 'items[1].stauts', 'items[2].id'], array_keys($fields));
|
||||
self::assertStringContainsString('archiviert', $fields['items[0].delete']);
|
||||
self::assertSame('unbekanntes Feld', $fields['items[1].stauts']);
|
||||
self::assertSame([], $this->saves);
|
||||
self::assertFalse($this->ability()->inputSchema()['properties']['items']['items']['additionalProperties']);
|
||||
}
|
||||
|
||||
/** Divi silently drops variables with an empty label or the label "0" (sanitize_global_variables_data). */
|
||||
public function testEmptyAndZeroLabelsAreRefused(): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user