feat: read the Divi design system live – lit/divi-design-system
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Design;
|
||||
|
||||
use Brain\Monkey\Functions;
|
||||
use LIT\MCP\Integrations\Divi\Design\DesignSystemReader;
|
||||
use LIT\MCP\Integrations\Divi\Design\DiviDesignSystemAbility;
|
||||
use LIT\MCP\Tests\Unit\TestCase;
|
||||
use Mockery;
|
||||
|
||||
final class DiviDesignSystemAbilityTest extends TestCase
|
||||
{
|
||||
public function testReturnsDesignSystemWithPlaceholders(): void
|
||||
{
|
||||
$reader = Mockery::mock(DesignSystemReader::class);
|
||||
$reader->allows('read')->andReturn(DesignSystemTest::sample());
|
||||
Functions\when('current_user_can')->justReturn(true);
|
||||
$ability = new DiviDesignSystemAbility($reader);
|
||||
|
||||
self::assertTrue($ability->permission([]));
|
||||
$result = $ability->execute([]);
|
||||
|
||||
self::assertSame('{{color:primary}}', $result['colors'][0]['placeholder']);
|
||||
self::assertSame('{{color:Nachtblau}}', $result['colors'][2]['placeholder']);
|
||||
self::assertSame('{{var:Telefon}}', $result['variables'][1]['placeholder']);
|
||||
self::assertSame(['heading' => 'Open Sans', 'body' => 'Lato'], $result['fonts']);
|
||||
self::assertSame('CTA primär', $result['presets'][1]['name']);
|
||||
self::assertStringContainsString('{{font:heading}}', $result['notes'][0]);
|
||||
self::assertTrue($ability->isDirect());
|
||||
self::assertSame(['colors', 'variables', 'fonts', 'sizes', 'presets', 'notes'], $ability->outputSchema()['required']);
|
||||
}
|
||||
|
||||
public function testNeedsEditPosts(): void
|
||||
{
|
||||
Functions\when('current_user_can')->justReturn(false);
|
||||
|
||||
$result = (new DiviDesignSystemAbility(Mockery::mock(DesignSystemReader::class)))->permission([]);
|
||||
|
||||
self::assertSame('lit_forbidden', $result->get_error_code());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user