refactor: Kern ohne Divi – Ports BuilderDetector, MediaUsageSource, EnvironmentComponent und ausgeschlossene Post-Typen im ContentSchema; Divi-Implementierungen und Verdrahtung über DiviIntegration/Plugin; CoreIndependenceTest

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Jan-Niclas Loosen
2026-10-18 21:49:28 +02:00
co-authored by Claude Sonnet 5.5
parent abeb4b0eed
commit 06148fb8c1
33 changed files with 952 additions and 154 deletions
@@ -6,8 +6,14 @@ namespace LIT\MCP\Tests\Unit\Integrations\Divi;
use Brain\Monkey\Functions;
use LIT\MCP\Abilities\Ability;
use LIT\MCP\Integrations\Core\EnvironmentComponent;
use LIT\MCP\Integrations\Divi\DiviBuilderDetector;
use LIT\MCP\Integrations\Divi\DiviEnvironmentComponent;
use LIT\MCP\Integrations\Divi\DiviIntegration;
use LIT\MCP\Integrations\Divi\DiviLogoUsage;
use LIT\MCP\Integrations\Divi\Pages\DiviContentComposer;
use LIT\MCP\Integrations\Media\MediaUsageSource;
use LIT\MCP\Integrations\WordPress\BuilderDetector;
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
use LIT\MCP\Tests\Support\FakeChangeLog;
use LIT\MCP\Tests\Support\LibraryFixtures;
@@ -58,6 +64,43 @@ final class DiviIntegrationTest extends TestCase
}
}
/** Spec §3: the ports the core uses (Plugin wires them) are Divi's own implementations. */
public function testProvidesThePortsTheCoreUses(): void
{
$integration = new DiviIntegration(Mockery::mock(ContentSchema::class), FakeChangeLog::forbidden());
self::assertInstanceOf(BuilderDetector::class, $integration->builderDetector());
self::assertInstanceOf(DiviBuilderDetector::class, $integration->builderDetector());
$sources = $integration->mediaUsageSources();
self::assertCount(1, $sources);
self::assertInstanceOf(MediaUsageSource::class, $sources[0]);
self::assertInstanceOf(DiviLogoUsage::class, $sources[0]);
self::assertInstanceOf(EnvironmentComponent::class, $integration->environmentComponent());
self::assertInstanceOf(DiviEnvironmentComponent::class, $integration->environmentComponent());
}
/** The content tools leave the same post types alone as before the schema stopped knowing Divi. */
public function testDiviPostTypesAddedToTheSchemaGiveTheFormerExcludedList(): void
{
self::assertSame(
[
'attachment', 'nav_menu_item', 'revision', 'wp_block', 'wp_template', 'wp_template_part',
'wp_navigation', 'wp_global_styles', 'wp_font_family', 'wp_font_face', 'et_pb_layout',
'et_theme_builder', 'et_template', 'et_header_layout', 'et_body_layout', 'et_footer_layout',
'et_pb_canvas', '_et_pb_speculation',
],
array_merge(ContentSchema::EXCLUDED, DiviIntegration::internalPostTypes())
);
}
public function testTheSchemaAsksDiviWhetherTheBuilderIsOnForAPostType(): void
{
Functions\when('et_builder_enabled_for_post_type')->alias(static fn (string $type): bool => $type === 'page');
self::assertTrue(DiviIntegration::builderEnabledFor('page'));
self::assertFalse(DiviIntegration::builderEnabledFor('post'));
}
public function testProvidesTheLibraryGroup(): void
{
Functions\when('__')->returnArg();