Die generische CheckRoute (POST lit-mcp/v1/<id>-check, für Divi weiter /divi-check) ersetzt DiviCheckRoute: Lock je Profil mit Besitzer-Token, Bericht je Profil, Rücksprung auf den neuen Reiter und Hook lit_mcp_compat_changed (Divi lädt darauf seinen Freigabe-Status neu). Der Reiter „Compatibility“ zeigt je Plugin Zustand (Wort und Icon), Hinweis zur Stufe, Fähigkeiten, getestete und freigegebene Versionen und den letzten Bericht, mit Prüfen, Freigeben und Zurückziehen (Recht manage_options, Allowlist der Profil-ID, Nonce je Profil). Freigeben serverseitig nur mit frischem grünem Bericht. Der Load-Hook lit_mcp_compat_profile_load bereitet den Abbau des DiviTab vor, der bis dahin parallel läuft. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
109 lines
4.0 KiB
PHP
109 lines
4.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace LIT\MCP\Tests\Unit\Compatibility;
|
|
|
|
use LIT\MCP\Compatibility\CompatibilityMatrix;
|
|
use LIT\MCP\Compatibility\CheckStep;
|
|
use LIT\MCP\Compatibility\ManifestCheck;
|
|
use LIT\MCP\Compatibility\Profile;
|
|
use LIT\MCP\Compatibility\Tier;
|
|
use LIT\MCP\Tests\Support\FakeCapability;
|
|
use LIT\MCP\Tests\Unit\TestCase;
|
|
use LogicException;
|
|
|
|
final class ProfileTest extends TestCase
|
|
{
|
|
public function testAProfileKeepsWhatItWasGiven(): void
|
|
{
|
|
$matrix = static fn (): CompatibilityMatrix => CompatibilityMatrix::allReleased([FakeCapability::Read]);
|
|
$profile = new Profile(
|
|
id: 'fake',
|
|
label: 'Fake Plugin',
|
|
tier: Tier::ReleasePerVersion,
|
|
capabilities: [FakeCapability::Read],
|
|
matrix: $matrix,
|
|
minVersion: '2.0'
|
|
);
|
|
|
|
self::assertSame('fake', $profile->id);
|
|
self::assertSame('Fake Plugin', $profile->label);
|
|
self::assertSame(Tier::ReleasePerVersion, $profile->tier);
|
|
self::assertSame([FakeCapability::Read], $profile->capabilities);
|
|
self::assertSame($matrix, $profile->matrix);
|
|
self::assertSame('2.0', $profile->minVersion);
|
|
self::assertSame([], $profile->manifests);
|
|
}
|
|
|
|
public function testTheStoredVersionKeyDefaultsToVersionAndIsKeptWhenGiven(): void
|
|
{
|
|
$plain = new Profile(id: 'fake', label: 'Fake', tier: Tier::ReportOnly, capabilities: [FakeCapability::Read]);
|
|
$divi = new Profile(
|
|
id: 'fake',
|
|
label: 'Fake',
|
|
tier: Tier::ReportOnly,
|
|
capabilities: [FakeCapability::Read],
|
|
reportVersionKey: 'divi_version'
|
|
);
|
|
|
|
self::assertSame('version', $plain->reportVersionKey);
|
|
self::assertSame('divi_version', $divi->reportVersionKey);
|
|
}
|
|
|
|
public function testTheReleaseFieldsAreOptionalAndKeptWhenGiven(): void
|
|
{
|
|
$bare = new Profile(id: 'fake', label: 'Fake', tier: Tier::ReportOnly, capabilities: [FakeCapability::Read]);
|
|
self::assertSame([], $bare->testedVersions);
|
|
self::assertNull($bare->stateKey);
|
|
self::assertNull($bare->extraSteps);
|
|
self::assertNull($bare->manifestCheck);
|
|
self::assertNull($bare->stepLabel);
|
|
|
|
$stateKey = static fn (string $version): string => 'k' . $version;
|
|
$extraSteps = static fn (bool $manifestClean): array => [];
|
|
$manifestCheck = static fn (): ManifestCheck => new ManifestCheck([], signatures: false);
|
|
$stepLabel = static fn (CheckStep $step): string => 'L' . $step->key;
|
|
$full = new Profile(
|
|
id: 'fake',
|
|
label: 'Fake',
|
|
tier: Tier::ReportOnly,
|
|
capabilities: [FakeCapability::Read],
|
|
testedVersions: ['1.0'],
|
|
stateKey: $stateKey,
|
|
extraSteps: $extraSteps,
|
|
manifestCheck: $manifestCheck,
|
|
stepLabel: $stepLabel
|
|
);
|
|
self::assertSame(['1.0'], $full->testedVersions);
|
|
self::assertSame($stateKey, $full->stateKey);
|
|
self::assertSame($extraSteps, $full->extraSteps);
|
|
self::assertSame($manifestCheck, $full->manifestCheck);
|
|
self::assertSame($stepLabel, $full->stepLabel);
|
|
}
|
|
|
|
public function testAReleasePerVersionProfileWithoutMatrixIsAProgrammingError(): void
|
|
{
|
|
$this->expectException(LogicException::class);
|
|
$this->expectExceptionMessage('needs a matrix closure');
|
|
|
|
new Profile(id: 'fake', label: 'Fake', tier: Tier::ReleasePerVersion, capabilities: [FakeCapability::Read]);
|
|
}
|
|
|
|
public function testCapabilityIdsMustBeUniqueWithinAProfile(): void
|
|
{
|
|
$this->expectException(LogicException::class);
|
|
$this->expectExceptionMessage('fake-read');
|
|
|
|
new Profile(id: 'fake', label: 'Fake', tier: Tier::ReportOnly, capabilities: [FakeCapability::Read, FakeCapability::Read]);
|
|
}
|
|
|
|
public function testTheTiersHaveStableValues(): void
|
|
{
|
|
self::assertSame(
|
|
['report', 'lock', 'release'],
|
|
array_map(static fn (Tier $t): string => $t->value, Tier::cases())
|
|
);
|
|
}
|
|
}
|