docs: Theme Builder guide, instructions, readme and spec for 0.5.0

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-27 22:05:33 +02:00
co-authored by Claude Opus 5.5
parent 4e959833b9
commit 3db96a3f5b
14 changed files with 364 additions and 45 deletions
@@ -104,6 +104,58 @@ final class InstructionsBuilderTest extends TestCase
}
}
private function themeBuilder(): Integration
{
$group = Mockery::mock(Integration::class);
$group->allows('id')->andReturn('divi-theme-builder');
$group->allows('isAvailable')->andReturn(true);
$activate = $this->ability('lit/tb-activate', false);
$activate->allows('annotations')->andReturn(['readonly' => false]);
$group->allows('abilities')->andReturn([$activate]);
return $group;
}
public function testAddsTheThemeBuilderRuleOnlyWhenItsGroupCanWrite(): void
{
$core = $this->coreWith($this->ability('lit/guide', true));
$registry = new IntegrationRegistry($core, $this->themeBuilder());
$with = (new InstructionsBuilder($registry))->build();
$without = (new InstructionsBuilder(new IntegrationRegistry($core)))->build();
self::assertStringContainsString('Divi Theme Builder: neue Vorlagen entstehen deaktiviert', $with);
self::assertStringContainsString('lit/tb-activate', $with);
self::assertStringContainsString('confirm: true', $with);
self::assertStringContainsString('topic "theme-builder"', $with);
self::assertStringNotContainsString('Divi Theme Builder:', $without);
self::assertLessThan(2000, strlen($with));
foreach ([['@readonly:divi-theme-builder' => true], ['@group:divi-theme-builder' => 'disabled']] as $settings) {
$policy = (new ExposurePolicy($settings))->withGroups($registry->groupMap());
$text = (new InstructionsBuilder($registry, null, $policy))->build();
self::assertStringNotContainsString('Divi Theme Builder:', $text, (string) json_encode($settings));
}
}
public function testAllRulesTogetherStayShort(): void
{
$divi = Mockery::mock(Integration::class);
$divi->allows('id')->andReturn('divi');
$divi->allows('isAvailable')->andReturn(true);
$divi->allows('abilities')->andReturn([$this->ability('lit/divi-outline', true)]);
$core = $this->coreWith($this->ability('lit/guide', true));
$registry = new IntegrationRegistry($core, $divi, $this->library(), $this->themeBuilder());
$text = (new InstructionsBuilder($registry, static fn (): array => ['page', 'post']))->build();
self::assertStringContainsString('Divi-Bibliothek:', $text);
self::assertStringContainsString('Divi Theme Builder:', $text);
self::assertLessThan(2000, strlen($text));
}
public function testListsPostTypesWhenAProviderIsGiven(): void
{
$core = $this->coreWith($this->ability('lit/guide', true));
@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Pages;
use LIT\MCP\Integrations\Divi\Pages\DiviSchema;
use LIT\MCP\Tests\Unit\TestCase;
final class DiviSchemaTest extends TestCase
{
/** Ruling Q17 M2: confirm also applies to layouts of active Theme Builder templates. */
public function testTheConfirmDescriptionNamesEveryCaseThatNeedsADryRun(): void
{
$description = (string) DiviSchema::write()['confirm']['description'];
self::assertStringContainsString('globalen Bibliothekseinträgen', $description);
self::assertStringContainsString('Theme-Builder-Layouts aktiver Vorlagen', $description);
self::assertStringContainsString('Löschen', $description);
self::assertStringContainsString('confirm_required', $description);
}
}