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:
co-authored by
Claude Sonnet 5.5
parent
abeb4b0eed
commit
06148fb8c1
@@ -4,8 +4,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Tests\Unit\Integrations\Core;
|
||||
|
||||
use Brain\Monkey\Functions;
|
||||
use LIT\MCP\Integrations\Core\CoreIntegration;
|
||||
use LIT\MCP\Integrations\Core\EnvironmentComponent;
|
||||
use LIT\MCP\Tests\Unit\TestCase;
|
||||
use WP_User;
|
||||
|
||||
final class CoreIntegrationTest extends TestCase
|
||||
{
|
||||
@@ -20,4 +23,23 @@ final class CoreIntegrationTest extends TestCase
|
||||
array_map(static fn ($a) => $a->name(), $core->abilities())
|
||||
);
|
||||
}
|
||||
|
||||
public function testSiteStatusReportsTheComponentsOfTheIntegrations(): void
|
||||
{
|
||||
Functions\when('get_bloginfo')->justReturn('x');
|
||||
Functions\when('home_url')->justReturn('https://kunde.de');
|
||||
Functions\when('wp_get_current_user')->justReturn(new WP_User(3, ['editor']));
|
||||
Functions\when('get_option')->justReturn(['editor']);
|
||||
$component = new class implements EnvironmentComponent {
|
||||
public function describe(): array
|
||||
{
|
||||
return ['id' => 'builder', 'active' => true, 'version' => '9', 'problems' => [], 'release' => null];
|
||||
}
|
||||
};
|
||||
$core = new CoreIntegration(dirname(__DIR__, 3) . '/Fixtures/guides', [$component]);
|
||||
|
||||
$status = $core->abilities()[1]->execute([]);
|
||||
|
||||
self::assertSame(['builder', 'pods', 'the-events-calendar'], array_column($status['components'], 'id'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,44 +4,51 @@ declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Tests\Unit\Integrations\Core;
|
||||
|
||||
use Brain\Monkey\Functions;
|
||||
use LIT\MCP\Integrations\Core\EnvironmentComponent;
|
||||
use LIT\MCP\Integrations\Core\EnvironmentProbe;
|
||||
use LIT\MCP\Integrations\Divi\DiviCompatibility;
|
||||
use LIT\MCP\Tests\Unit\TestCase;
|
||||
use Mockery;
|
||||
|
||||
final class EnvironmentProbeTest extends TestCase
|
||||
{
|
||||
public function testDiviComponentCarriesTheCompatibilityFindings(): void
|
||||
private function component(string $id, array $problems = []): EnvironmentComponent
|
||||
{
|
||||
$theme = Mockery::mock();
|
||||
$theme->allows('get_template')->andReturn('Divi');
|
||||
$theme->allows('parent')->andReturn(false);
|
||||
$theme->allows('get')->with('Version')->andReturn('5.2.1');
|
||||
Functions\when('wp_get_theme')->justReturn($theme);
|
||||
return new class ($id, $problems) implements EnvironmentComponent {
|
||||
public function __construct(private string $id, private array $problems)
|
||||
{
|
||||
}
|
||||
|
||||
$probe = new EnvironmentProbe(new DiviCompatibility(['GlobalLayout' => static fn (): bool => false]));
|
||||
$components = array_column($probe->components(), null, 'id');
|
||||
|
||||
self::assertSame(['GlobalLayout'], $components['divi']['problems']);
|
||||
self::assertSame([], $components['pods']['problems']);
|
||||
public function describe(): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'active' => true,
|
||||
'version' => '1.2.3',
|
||||
'problems' => $this->problems,
|
||||
'release' => ['state' => 'released'],
|
||||
];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public function testDiviComponentCarriesTheReleaseStatus(): void
|
||||
public function testGivenComponentsComeFirstInTheOrderGivenFollowedByPodsAndTheEventsCalendar(): void
|
||||
{
|
||||
$theme = Mockery::mock();
|
||||
$theme->allows('get_template')->andReturn('Divi');
|
||||
$theme->allows('parent')->andReturn(false);
|
||||
$theme->allows('get')->with('Version')->andReturn('5.2.1');
|
||||
Functions\when('wp_get_theme')->justReturn($theme);
|
||||
$probe = new EnvironmentProbe([$this->component('builder', ['Etwas fehlt']), $this->component('shop')]);
|
||||
|
||||
$components = array_column(
|
||||
(new EnvironmentProbe(new DiviCompatibility([])))->components(),
|
||||
null,
|
||||
'id'
|
||||
);
|
||||
$components = $probe->components();
|
||||
|
||||
self::assertSame('released', $components['divi']['release']['state'] ?? null);
|
||||
self::assertNull($components['pods']['release'] ?? null);
|
||||
self::assertSame(['builder', 'shop', 'pods', 'the-events-calendar'], array_column($components, 'id'));
|
||||
self::assertSame(['Etwas fehlt'], $components[0]['problems']);
|
||||
self::assertSame(['state' => 'released'], $components[1]['release']);
|
||||
}
|
||||
|
||||
public function testWithoutComponentsOnlyPodsAndTheEventsCalendarAreReported(): void
|
||||
{
|
||||
$components = array_column((new EnvironmentProbe())->components(), null, 'id');
|
||||
|
||||
self::assertSame(['pods', 'the-events-calendar'], array_keys($components));
|
||||
self::assertFalse($components['pods']['active'], 'no Pods in unit tests');
|
||||
self::assertSame([], $components['pods']['problems']);
|
||||
self::assertNull($components['pods']['release']);
|
||||
self::assertNull($components['the-events-calendar']['version']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user