Files
Jan-Niclas LoosenandClaude Opus 5.5 85f4138b36 feat(admin): Prüfroute je Profil und Reiter „Compatibility“
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>
2026-11-06 13:15:59 +01:00

82 lines
3.3 KiB
PHP

<?php
declare(strict_types=1);
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Release;
use Brain\Monkey\Functions;
use LIT\MCP\Compatibility\CheckStep;
use LIT\MCP\Compatibility\ManifestCheck;
use LIT\MCP\Compatibility\ReleaseState;
use LIT\MCP\Compatibility\Tier;
use LIT\MCP\Integrations\Divi\Release\DiviAdapters;
use LIT\MCP\Integrations\Divi\Release\DiviCheckSteps;
use LIT\MCP\Integrations\Divi\Release\DiviFeature;
use LIT\MCP\Integrations\Divi\Release\DiviProfile;
use LIT\MCP\Integrations\Divi\Release\DiviReleases;
use LIT\MCP\Integrations\Divi\Release\ReleaseGate;
use LIT\MCP\Integrations\Divi\Release\ReleaseResolver;
use LIT\MCP\Tests\Support\ReleaseMatrices;
use LIT\MCP\Tests\Unit\TestCase;
use Mockery;
final class DiviProfileTest extends TestCase
{
private function theme(string $template, string $version = '5.2.1'): void
{
$theme = Mockery::mock();
$theme->allows('get_template')->andReturn($template);
$theme->allows('parent')->andReturn(false);
$theme->allows('get')->with('Version')->andReturn($version);
Functions\when('wp_get_theme')->justReturn($theme);
}
public function testDescribesDiviAsAReleasePerVersionPlugin(): void
{
$profile = DiviProfile::profile();
self::assertSame('divi', $profile->id);
self::assertSame('Divi', $profile->label);
self::assertSame('divi_version', $profile->reportVersionKey, 'stored Divi data keeps its key');
self::assertSame(DiviProfile::ID, $profile->id);
self::assertSame(DiviProfile::REPORT_VERSION_KEY, $profile->reportVersionKey);
self::assertSame(Tier::ReleasePerVersion, $profile->tier);
self::assertSame(DiviFeature::cases(), $profile->capabilities);
self::assertEquals(array_values(DiviAdapters::manifests()), $profile->manifests);
}
public function testTheMatrixIsTheReleaseGatesMatrix(): void
{
$status = ReleaseMatrices::status([DiviFeature::PageWrite], ReleaseState::Incompatible);
ReleaseGate::useResolver(static fn () => $status);
self::assertSame($status->matrix, (DiviProfile::profile()->matrix)());
}
public function testTheVersionComesFromTheDiviTemplateAndActiveMeansDiviIsInstalled(): void
{
$this->theme('Divi', '5.3.0');
$profile = DiviProfile::profile();
self::assertTrue(($profile->active)());
self::assertSame('5.3.0', ($profile->version)());
$this->theme('twentytwentyfive');
self::assertFalse(($profile->active)());
self::assertNull(($profile->version)());
}
public function testCarriesTestedVersionsStateKeyAndManifestCheck(): void
{
$this->theme('twentytwentyfive');
$profile = DiviProfile::profile();
self::assertSame(DiviReleases::TESTED, $profile->testedVersions);
self::assertSame(ReleaseResolver::stateKey('5.3.0'), ($profile->stateKey)('5.3.0'));
self::assertInstanceOf(ManifestCheck::class, ($profile->manifestCheck)());
// Reports saved before step labels were stored still get their Divi labels.
$old = new CheckStep(DiviCheckSteps::WRITE, []);
self::assertSame(DiviCheckSteps::label($old), ($profile->stepLabel)($old));
self::assertNotSame(DiviCheckSteps::WRITE, ($profile->stepLabel)($old));
}
}