Files
Jan-Niclas LoosenandClaude Opus 5.5 c85131603b feat(compat): Profile, Gates und Pods über den Kompatibilitätskern
Neu: Tier, Profile, Compatibility, CapabilityLocked, CapabilityGate, CompatibilityComponent, ProvidesCompatibility, DiviProfile sowie PodsFeature, PodsCompatibility und PodsIntegration. Das CapabilityGate sperrt gesperrte und unbekannte Fähigkeits-IDs (übernimmt die Sperre unbekannter IDs vom DiviFeatureGate) und delegiert nur Divi ausdrücklich. Pods-Schema, -Lesen, -Schreiben und -Feldrechte laufen über usable(PodsFeature::…); Schreiben verlangt FieldRead und FieldWrite, damit ein Rollback keine Werte verliert. lit-site-status meldet Pods über die CompatibilityComponent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 12:26:54 +01:00

68 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
namespace LIT\MCP\Tests\Unit\Integrations\Core;
use LIT\MCP\Integrations\Core\EnvironmentComponent;
use LIT\MCP\Integrations\Core\EnvironmentProbe;
use LIT\MCP\Tests\Unit\TestCase;
final class EnvironmentProbeTest extends TestCase
{
private function component(string $id, array $problems = []): EnvironmentComponent
{
return new class ($id, $problems) implements EnvironmentComponent {
public function __construct(private string $id, private array $problems)
{
}
public function describe(): array
{
return [
'id' => $this->id,
'active' => true,
'version' => '1.2.3',
'problems' => $this->problems,
'release' => ['state' => 'released'],
];
}
};
}
public function testGivenComponentsComeFirstInTheOrderGivenFollowedByTheEventsCalendar(): void
{
$probe = new EnvironmentProbe(fn (): array => [$this->component('builder', ['Etwas fehlt']), $this->component('shop')]);
$components = $probe->components();
self::assertSame(['builder', 'shop', 'the-events-calendar'], array_column($components, 'id'));
self::assertSame(['Etwas fehlt'], $components[0]['problems']);
self::assertSame(['state' => 'released'], $components[1]['release']);
}
public function testComponentsMayBeGivenLazilyAndAreAskedPerCall(): void
{
$asked = 0;
$probe = new EnvironmentProbe(function () use (&$asked): array {
$asked++;
return [$this->component('lazy')];
});
self::assertSame(0, $asked);
self::assertSame(['lazy', 'the-events-calendar'], array_column($probe->components(), 'id'));
$probe->components();
self::assertSame(2, $asked, 'asked per call, never cached: the state may change within a request');
}
public function testWithoutComponentsOnlyTheEventsCalendarIsReported(): void
{
$components = array_column((new EnvironmentProbe())->components(), null, 'id');
self::assertSame(['the-events-calendar'], array_keys($components));
self::assertNull($components['the-events-calendar']['version']);
self::assertNull($components['the-events-calendar']['release']);
}
}