refactor: Divi library adapters with manifest and submit-layout mirror
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,8 @@ use Brain\Monkey\Functions;
|
||||
use LIT\MCP\Abilities\WriteFailed;
|
||||
use LIT\MCP\Integrations\Divi\Library\DiviLibraryStore;
|
||||
use LIT\MCP\Integrations\Divi\Library\LibraryItemSpec;
|
||||
use LIT\MCP\Integrations\Divi\Release\DiviAdapters;
|
||||
use LIT\MCP\Integrations\Divi\Release\Manifest;
|
||||
use LIT\MCP\Integrations\WordPress\Content\NewDraft;
|
||||
use LIT\MCP\Tests\Support\FakeChangeLog;
|
||||
use LIT\MCP\Tests\Unit\TestCase;
|
||||
@@ -114,6 +116,32 @@ final class DiviLibraryStoreTest extends TestCase
|
||||
self::assertSame(12, $captured['author']);
|
||||
}
|
||||
|
||||
public function testIsTheRegisteredLibraryAdapterWithTheSubmitLayoutMirror(): void
|
||||
{
|
||||
$manifest = DiviLibraryStore::manifest();
|
||||
|
||||
self::assertContains(DiviLibraryStore::class, DiviAdapters::CLASSES);
|
||||
self::assertSame(Manifest::LIBRARY, $manifest->area);
|
||||
self::assertSame(['et_pb_layout'], $manifest->postTypes);
|
||||
self::assertSame(
|
||||
['scope', 'layout_type', 'module_width', 'layout_category', 'layout_tag'],
|
||||
$manifest->taxonomies
|
||||
);
|
||||
self::assertSame(['library-submit-layout'], array_map(static fn ($m): string => $m->id, $manifest->mirrors));
|
||||
self::assertSame('et_pb_submit_layout()', $manifest->mirrors[0]->label());
|
||||
}
|
||||
|
||||
public function testBuiltForReadsTheSourceType(): void
|
||||
{
|
||||
Functions\when('get_post_meta')->alias(
|
||||
static fn (int $id, string $key): string => $id === 1054
|
||||
&& $key === '_et_pb_built_for_post_type' ? 'post' : ''
|
||||
);
|
||||
|
||||
self::assertSame('post', DiviLibraryStore::builtFor(1054));
|
||||
self::assertSame('', DiviLibraryStore::builtFor(1055));
|
||||
}
|
||||
|
||||
public function testReportsMissingTaxonomies(): void
|
||||
{
|
||||
Functions\when('taxonomy_exists')->alias(static fn (string $taxonomy): bool => $taxonomy !== 'scope');
|
||||
|
||||
@@ -26,4 +26,10 @@ final class DiviRolesTest extends TestCase
|
||||
// Unit tests have no et_pb_is_allowed(): a missing Divi function never means "allowed".
|
||||
self::assertFalse((new DiviRoles())->allows('divi_library'));
|
||||
}
|
||||
|
||||
public function testIsTheRegisteredRolesAdapter(): void
|
||||
{
|
||||
self::assertContains(DiviRoles::class, \LIT\MCP\Integrations\Divi\Release\DiviAdapters::CLASSES);
|
||||
self::assertSame('et_pb_is_allowed()', DiviRoles::manifest()->calls[0]->label());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ use LIT\MCP\Integrations\Divi\BlockTree\Block;
|
||||
use LIT\MCP\Integrations\Divi\BlockTree\LibraryContent;
|
||||
use LIT\MCP\Integrations\Divi\BlockTree\NodeIndex;
|
||||
use LIT\MCP\Integrations\Divi\BlockTree\Parser;
|
||||
use LIT\MCP\Integrations\Divi\Library\DiviLibraryStore;
|
||||
use LIT\MCP\Integrations\Divi\Library\LibraryItemSpec;
|
||||
use LIT\MCP\Tests\Support\DiviFixtures;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@@ -60,7 +61,7 @@ final class LibraryItemSpecTest extends TestCase
|
||||
self::assertEquals($expectedTerms, $spec->terms());
|
||||
$expectedMeta = array_map(static fn (array $values): string => $values[0], $json['meta']);
|
||||
unset($expectedMeta['_et_pb_row_layout']);
|
||||
self::assertEquals($expectedMeta, $spec->meta());
|
||||
self::assertEquals($expectedMeta, DiviLibraryStore::metaFor($spec));
|
||||
}
|
||||
|
||||
public function testRefusesInstancesColumnsAndGlobalsInsideGlobals(): void
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace LIT\MCP\Tests\Unit\Integrations\Divi\Library;
|
||||
use Brain\Monkey\Functions;
|
||||
use LIT\MCP\Abilities\Rev;
|
||||
use LIT\MCP\Abilities\WriteFailed;
|
||||
use LIT\MCP\Integrations\Divi\Library\DiviLibraryStore;
|
||||
use LIT\MCP\Integrations\Divi\Library\LibraryItemSpec;
|
||||
use LIT\MCP\Integrations\Divi\Library\LibrarySaveAbility;
|
||||
use LIT\MCP\Integrations\Divi\Pages\DiviSaver;
|
||||
@@ -112,8 +113,8 @@ final class LibrarySaveAbilityTest extends TestCase
|
||||
|
||||
self::assertTrue($result['ok']);
|
||||
self::assertTrue($this->specs[0]->global);
|
||||
self::assertSame('divi/button', $this->specs[0]->meta()['_et_pb_module_type']);
|
||||
self::assertSame('[]', $this->specs[0]->meta()['_et_pb_excluded_global_options']);
|
||||
self::assertSame('divi/button', DiviLibraryStore::metaFor($this->specs[0])['_et_pb_module_type']);
|
||||
self::assertSame('[]', DiviLibraryStore::metaFor($this->specs[0])['_et_pb_excluded_global_options']);
|
||||
}
|
||||
|
||||
public function testRefusesAGlobalInstanceAndColumnsAndCreatesNothing(): void
|
||||
|
||||
@@ -26,10 +26,6 @@ final class DiviBoundaryTest extends TestCase
|
||||
private const LEGACY = [
|
||||
'Integrations/Divi/Design/DesignSystemReader.php',
|
||||
'Integrations/Divi/DiviCompatibility.php',
|
||||
'Integrations/Divi/Library/DiviLibraryStore.php',
|
||||
'Integrations/Divi/Library/DiviRoles.php',
|
||||
'Integrations/Divi/Library/LibraryItemSpec.php',
|
||||
'Integrations/Divi/Library/NewLibraryEntry.php',
|
||||
'Integrations/Divi/ThemeBuilder/DiviThemeBuilder.php',
|
||||
'Integrations/Media/MediaUsageFinder.php',
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user