test: shared Divi fixtures in tests/Support (T1)
- 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>
This commit is contained in:
@@ -5,46 +5,14 @@ declare(strict_types=1);
|
||||
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Design;
|
||||
|
||||
use LIT\MCP\Integrations\Divi\Design\DesignSystem;
|
||||
use LIT\MCP\Tests\Support\DiviFixtures;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class DesignSystemTest extends TestCase
|
||||
{
|
||||
/** Shapes as GlobalData / GlobalPreset return them (Divi 5.2.1, verified in DDEV). */
|
||||
public static function sample(): DesignSystem
|
||||
{
|
||||
return DesignSystem::fromDivi(
|
||||
[
|
||||
'gcid-primary-color' => ['color' => '#2ea3f2', 'label' => 'Primärfarbe', 'status' => 'active'],
|
||||
'gcid-body-color' => ['color' => '#666666', 'label' => 'Fließtextfarbe', 'status' => 'active'],
|
||||
'gcid-a1b2' => ['color' => '#0b3d59', 'label' => 'Nachtblau', 'status' => 'active'],
|
||||
'gcid-old' => ['color' => '#ff0000', 'label' => 'Alt', 'status' => 'inactive'],
|
||||
],
|
||||
[
|
||||
'numbers' => ['gvid-r1' => ['id' => 'gvid-r1', 'label' => 'Radius', 'value' => '8px', 'status' => 'active']],
|
||||
'strings' => ['gvid-s1' => ['id' => 'gvid-s1', 'label' => 'Telefon', 'value' => '0221 123', 'status' => 'active']],
|
||||
// Divi returns every variable type as stdClass (verified in DDEV).
|
||||
'fonts' => (object) [
|
||||
'--et_global_heading_font' => ['id' => '--et_global_heading_font', 'label' => 'Überschrift', 'value' => 'Open Sans', 'status' => 'active'],
|
||||
'--et_global_body_font' => ['id' => '--et_global_body_font', 'label' => 'Fließtext', 'value' => 'Lato', 'status' => 'active'],
|
||||
],
|
||||
'links' => new \stdClass(),
|
||||
],
|
||||
[
|
||||
'module' => ['divi/button' => ['default' => 'p-1', 'items' => [
|
||||
'p-1' => ['id' => 'p-1', 'name' => 'Standard', 'moduleName' => 'divi/button'],
|
||||
'p-2' => ['id' => 'p-2', 'name' => 'CTA primär', 'moduleName' => 'divi/button'],
|
||||
]]],
|
||||
'group' => ['divi/font' => ['default' => '', 'items' => [
|
||||
'g-1' => ['id' => 'g-1', 'name' => 'Fließtext groß', 'groupName' => 'divi/font'],
|
||||
]]],
|
||||
],
|
||||
['body_font_size' => '16']
|
||||
);
|
||||
}
|
||||
|
||||
public function testReadsColorsVariablesFontsSizesAndPresets(): void
|
||||
{
|
||||
$design = self::sample();
|
||||
$design = DiviFixtures::designSystem();
|
||||
|
||||
self::assertSame(
|
||||
['id' => 'gcid-a1b2', 'label' => 'Nachtblau', 'value' => '#0b3d59'],
|
||||
@@ -68,7 +36,7 @@ final class DesignSystemTest extends TestCase
|
||||
|
||||
public function testLooksUpByAliasLabelOrId(): void
|
||||
{
|
||||
$design = self::sample();
|
||||
$design = DiviFixtures::designSystem();
|
||||
|
||||
self::assertSame('gcid-primary-color', $design->colorId('primary'));
|
||||
self::assertSame('gcid-a1b2', $design->colorId('nachtblau'));
|
||||
|
||||
@@ -7,6 +7,7 @@ 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;
|
||||
|
||||
@@ -15,7 +16,7 @@ final class DiviDesignSystemAbilityTest extends TestCase
|
||||
public function testReturnsDesignSystemWithPlaceholders(): void
|
||||
{
|
||||
$reader = Mockery::mock(DesignSystemReader::class);
|
||||
$reader->allows('read')->andReturn(DesignSystemTest::sample());
|
||||
$reader->allows('read')->andReturn(DiviFixtures::designSystem());
|
||||
Functions\when('current_user_can')->justReturn(true);
|
||||
$ability = new DiviDesignSystemAbility($reader);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user