feat: divi-check gibt die Matrix je Fähigkeit aus (Exit 2 bei nicht nutzbarer Fähigkeit); Texte nennen Fähigkeiten statt pauschal gesperrt

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Jan-Niclas Loosen
2026-10-18 22:29:38 +02:00
co-authored by Claude Sonnet 5.5
parent 2aef6e1154
commit a4faeda326
4 changed files with 204 additions and 45 deletions
+107 -2
View File
@@ -10,7 +10,14 @@ use LIT\MCP\Integrations\Divi\Release\CheckReport;
use LIT\MCP\Integrations\Divi\Release\CheckReportStore;
use LIT\MCP\Integrations\Divi\Release\CheckStep;
use LIT\MCP\Integrations\Divi\Release\CompatibilityCheck;
use LIT\MCP\Integrations\Divi\Release\CompatibilityMatrix;
use LIT\MCP\Integrations\Divi\Release\DiviFeature;
use LIT\MCP\Integrations\Divi\Release\DiviReference;
use LIT\MCP\Integrations\Divi\Release\ReleaseGate;
use LIT\MCP\Integrations\Divi\Release\ReleaseResolver;
use LIT\MCP\Integrations\Divi\Release\ReleaseState;
use LIT\MCP\Integrations\Divi\Release\ReleaseStatus;
use LIT\MCP\Tests\Support\MatrixFixtures;
use LIT\MCP\Tests\Unit\TestCase;
use Mockery;
use RuntimeException;
@@ -61,7 +68,8 @@ final class DiviCheckCommandTest extends TestCase
private function command(
array $problems = [],
bool $expectSave = false,
bool $noSourceDir = false
bool $noSourceDir = false,
?CompatibilityMatrix $matrix = null
): DiviCheckCommand {
$steps = array_map(
static fn (string $key): CheckStep => new CheckStep($key, $problems[$key] ?? []),
@@ -91,7 +99,8 @@ final class DiviCheckCommandTest extends TestCase
}
return $this->signatures;
}
},
$matrix === null ? null : static fn (): CompatibilityMatrix => $matrix
);
}
@@ -256,4 +265,100 @@ final class DiviCheckCommandTest extends TestCase
file_put_contents($file, "<?php\n" . $code . "\n");
}
}
public function testPrintsTheMatrixAfterTheReport(): void
{
self::assertSame(0, $this->command()->run([]));
$schreibtest = array_search('✓ Schreibtest auf einer Wegwerfseite', $this->lines, true);
$header = array_search('Fähigkeiten:', $this->lines, true);
self::assertIsInt($schreibtest);
self::assertIsInt($header);
self::assertGreaterThan($schreibtest, $header);
self::assertContains('✓ Seiten schreiben – freigegeben (code)', $this->lines);
self::assertContains('✓ Theme Builder lesen – freigegeben (code)', $this->lines);
}
public function testEveryFeatureGetsOneLine(): void
{
$this->command()->run([]);
$matrixLines = array_filter(
$this->lines,
static fn (string $line): bool => str_contains($line, ' – freigegeben')
);
self::assertCount(count(DiviFeature::cases()), $matrixLines);
}
public function testAnIncompatibleFeatureFailsWithItsProblemsIndented(): void
{
$matrix = MatrixFixtures::with(
DiviFeature::PageWrite,
ReleaseState::Incompatible,
'auto',
'Seiten: et_pb_x() fehlt'
);
$code = $this->command(matrix: $matrix)->run([]);
self::assertSame(2, $code);
self::assertContains('✗ Seiten schreiben – inkompatibel', $this->lines);
self::assertContains(' Seiten: et_pb_x() fehlt', $this->lines);
self::assertContains('✓ Seiten lesen – freigegeben (auto)', $this->lines);
}
public function testAnUntestedFeatureFailsWithExitTwoAlthoughTheReportIsGreen(): void
{
$matrix = MatrixFixtures::with(DiviFeature::Catalog, ReleaseState::Untested, 'auto');
$code = $this->command(expectSave: true, matrix: $matrix)->run([]);
self::assertSame(2, $code);
self::assertContains('– Modulkatalog – ungetestet', $this->lines);
}
public function testARedReportKeepsExitOneWhateverTheMatrixSays(): void
{
$red = [CheckStep::CATALOG => ['divi/text: unbekanntes Modul']];
$incompatible = MatrixFixtures::with(DiviFeature::Catalog, ReleaseState::Incompatible, 'auto', 'x');
self::assertSame(1, $this->command($red)->run([]));
self::assertSame(1, $this->command($red, matrix: $incompatible)->run([]));
}
public function testUpdateReferenceKeepsItsOwnExitCodeAndStillPrintsTheMatrix(): void
{
$this->writeDivi();
$matrix = MatrixFixtures::with(
DiviFeature::PageWrite,
ReleaseState::Incompatible,
'auto',
'Seiten: Nachbau geändert'
);
$code = $this->command([CheckStep::MIRRORS => ['geändert']], matrix: $matrix)
->run(['update-reference' => true]);
self::assertSame(0, $code);
self::assertContains('✗ Seiten schreiben – inkompatibel', $this->lines);
}
public function testWithoutAnInjectedMatrixTheStateIsComputedAfterTheCheck(): void
{
$order = [];
Functions\when('delete_transient')->alias(static function (string $key) use (&$order): bool {
$order[] = 'delete:' . $key;
return true;
});
ReleaseGate::useResolver(static function () use (&$order): ReleaseStatus {
$order[] = 'resolve';
return ReleaseStatus::released('5.3.0');
});
$this->command()->run([]);
self::assertSame(['delete:' . ReleaseResolver::CACHE, 'resolve'], $order);
}
}