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:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user