feat: Divi tools write library entries; global ones with dry run, confirm and backup (E2, F2)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-27 01:15:58 +02:00
co-authored by Claude Opus 5.5
parent 681bb755ff
commit d66ad36c2e
23 changed files with 1066 additions and 44 deletions
@@ -127,15 +127,28 @@ final class DiviPageLoaderTest extends TestCase
);
}
public function testLibraryItemsAreNotWritableYet(): void
public function testLibraryItemsAreWritableWhateverTheBuilderSettingOfTheirType(): void
{
LibraryFixtures::given([LibraryFixtures::item(1058)]);
LibraryFixtures::given([LibraryFixtures::item(1057)]);
$loader = new DiviPageLoader(DiviFixtures::schema(false), new Parser(), LibraryFixtures::access());
$page = $loader->loadWritable(1057);
self::assertInstanceOf(DiviPage::class, $page);
self::assertTrue($page->isLibraryItem());
}
public function testWritingALibraryItemNeedsTheLibraryAccessAndItsEditRights(): void
{
LibraryFixtures::given([LibraryFixtures::item(1057)]);
$schema = Mockery::mock(ContentSchema::class);
$schema->allows('isManaged')->with('et_pb_layout')->andReturn(false);
$result = (new DiviPageLoader($schema, new Parser(), LibraryFixtures::access()))->load(1058, true);
self::assertToolError($result, 'not_found');
self::assertToolError((new DiviPageLoader($schema))->loadWritable(1057), 'not_found');
self::assertToolError(
(new DiviPageLoader($schema, new Parser(), LibraryFixtures::access([], false)))->loadWritable(1057),
'forbidden'
);
}
/** Ruling P9: the group "Divi-Bibliothek" disabled hides library entries from the Divi read tools. */