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
@@ -0,0 +1,67 @@
<?php
declare(strict_types=1);
namespace LIT\MCP\Tests\Unit\Integrations\Divi;
use Brain\Monkey\Functions;
use LIT\MCP\Integrations\Divi\DiviLogoUsage;
use LIT\MCP\Integrations\Media\MediaUsageSource;
use LIT\MCP\Tests\Unit\TestCase;
final class DiviLogoUsageTest extends TestCase
{
private const POSSIBLE_LOGO = [
'post_id' => 0,
'title' => 'Divi-Logo',
'post_type' => 'option',
'where' => 'divi_logo',
'certainty' => 'möglicherweise',
];
private function stub(string $logo, string $file = '2026/09/foto-scaled.jpg'): void
{
Functions\when('get_post_meta')->justReturn($file);
Functions\when('get_option')->alias(
static fn (string $name): mixed => $name === 'et_divi' ? ['divi_logo' => $logo] : false
);
}
public function testIsAMediaUsageSource(): void
{
self::assertInstanceOf(MediaUsageSource::class, new DiviLogoUsage());
}
public function testTheLogoThatIsTheFileIsAPossibleUsage(): void
{
$this->stub('https://k.de/wp-content/uploads/2026/09/foto.jpg');
self::assertSame([self::POSSIBLE_LOGO], (new DiviLogoUsage())->usagesOf(33));
}
public function testAGeneratedSizeOfTheFileCountsToo(): void
{
$this->stub('https://k.de/wp-content/uploads/2026/09/foto-300x200.jpg');
self::assertSame([self::POSSIBLE_LOGO], (new DiviLogoUsage())->usagesOf(33));
}
public function testAnotherFileIsNoUsage(): void
{
$this->stub('https://k.de/wp-content/uploads/2026/09/anderes.jpg');
self::assertSame([], (new DiviLogoUsage())->usagesOf(33));
}
public function testWithoutALogoOrWithoutAFileThereIsNoUsage(): void
{
$this->stub('');
self::assertSame([], (new DiviLogoUsage())->usagesOf(33));
$this->stub('https://k.de/wp-content/uploads/2026/09/foto.jpg', '');
self::assertSame([], (new DiviLogoUsage())->usagesOf(33));
Functions\when('get_option')->justReturn(false);
self::assertSame([], (new DiviLogoUsage())->usagesOf(33));
}
}