feat(pods): Verhaltensprobe als Prüfschritt
Beim Prüfen schreibt und liest PodsProbe auf einem Wegwerf-Entwurf ein Textfeld genau so, wie LIT MCP es tut, vergleicht die Werte und löscht den Entwurf wieder. Bevorzugt von Pods angelegte Typen; ohne Pod mit Textfeld gilt der Schritt als grün mit Hinweis „nicht geprüft“. Ein roter Schritt sperrt Pods über die Berichtssperre. Liegengebliebene Probe-Einträge räumt der Load-Hook des Reiters auf. Pods-Smoke um Probe und Bereinigung erweitert. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
42aa4f8dc9
commit
1a294b7881
+85
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Tests\Unit\Integrations\Pods;
|
||||
|
||||
use Closure;
|
||||
use LIT\MCP\Compatibility\CheckStep;
|
||||
use LIT\MCP\Integrations\Pods\PodsCheckSteps;
|
||||
use LIT\MCP\Tests\Unit\TestCase;
|
||||
use RuntimeException;
|
||||
|
||||
final class PodsCheckStepsTest extends TestCase
|
||||
{
|
||||
/** Captures what Log::failure writes to the PHP error log while $run runs. */
|
||||
private function logged(Closure $run): string
|
||||
{
|
||||
$log = (string) tempnam(sys_get_temp_dir(), 'lit-mcp-log');
|
||||
$previous = ini_set('error_log', $log);
|
||||
try {
|
||||
$run();
|
||||
|
||||
return (string) file_get_contents($log);
|
||||
} finally {
|
||||
ini_set('error_log', (string) $previous);
|
||||
unlink($log);
|
||||
}
|
||||
}
|
||||
|
||||
public function testStepsAreSkippedWithARedManifestAndTheProbeIsNotRun(): void
|
||||
{
|
||||
$ran = false;
|
||||
$steps = (PodsCheckSteps::extra(static function () use (&$ran): array {
|
||||
$ran = true;
|
||||
|
||||
return [];
|
||||
}))(false);
|
||||
|
||||
self::assertCount(1, $steps);
|
||||
self::assertSame(PodsCheckSteps::PROBE, $steps[0]->key);
|
||||
self::assertTrue($steps[0]->skipped);
|
||||
self::assertFalse($ran);
|
||||
}
|
||||
|
||||
public function testTheStepCarriesTheProbeProblems(): void
|
||||
{
|
||||
$steps = (PodsCheckSteps::extra(static fn (): array => ['rot']))(true);
|
||||
|
||||
self::assertSame(['rot'], $steps[0]->problems);
|
||||
self::assertFalse($steps[0]->skipped);
|
||||
self::assertSame('Lese- und Schreibtest an einem Wegwerf-Eintrag', $steps[0]->label());
|
||||
}
|
||||
|
||||
/** No target is no red step: a skipped one would lock Pods on a site that has no pod yet (CheckReport::green()). */
|
||||
public function testWithoutATargetTheStepIsGreenAndSaysSo(): void
|
||||
{
|
||||
$steps = (PodsCheckSteps::extra(static fn (): ?array => null))(true);
|
||||
|
||||
self::assertTrue($steps[0]->green());
|
||||
self::assertStringContainsString('nicht geprüft', $steps[0]->label());
|
||||
}
|
||||
|
||||
public function testALateExceptionOfTheClosureIsStillGuarded(): void
|
||||
{
|
||||
$logged = $this->logged(function (): void {
|
||||
$steps = (PodsCheckSteps::extra(static fn (): never => throw new RuntimeException('boom')))(true);
|
||||
self::assertSame(['Prüfschritt abgebrochen (Details im PHP-Error-Log).'], $steps[0]->problems);
|
||||
});
|
||||
|
||||
self::assertStringContainsString('boom', $logged);
|
||||
}
|
||||
|
||||
public function testTheLabelOfAnOldStepComesFromTheKey(): void
|
||||
{
|
||||
self::assertSame(
|
||||
'Lese- und Schreibtest an einem Wegwerf-Eintrag',
|
||||
PodsCheckSteps::label(new CheckStep(PodsCheckSteps::PROBE, []))
|
||||
);
|
||||
self::assertSame(
|
||||
'Pods-Funktionen, Klassen und Registrierungen',
|
||||
PodsCheckSteps::label(new CheckStep(CheckStep::MANIFEST, []))
|
||||
);
|
||||
self::assertSame('other', PodsCheckSteps::label(new CheckStep('other', [])));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user