- DiviFixtures: markup(), givenPost(), schema(), designSystem(), catalog(), dynamicContentRegistry(), maliciousRefs() - moved verbatim out of DiviPageLoaderTest, DesignSystemTest, ModuleCatalogTest, DynamicContentMapTest and VariableRefTest (its malicious() provider now returns maliciousRefs()). - ComposeFixture moves to tests/Support. - DiviWriterFixture: modules(), designReader(), composition(), a recording saver(), log() and writer(&$saved, &$failures, unfiltered, loader) for the five tests that wired the Divi write stack by hand. No test cases or assertions changed (1397 / 5834). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
45 lines
1.7 KiB
PHP
45 lines
1.7 KiB
PHP
<?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\Support\DiviFixtures;
|
|
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(DiviFixtures::designSystem());
|
|
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());
|
|
}
|
|
}
|