feat: Divi-Freigabe je Fähigkeit – CompatibilityMatrix aus Problemen mit Art und Fähigkeiten (ManifestCheck::problems), automatische Freigabe unveränderter Fähigkeiten (Filter lit_mcp_divi_auto_release), Mirror-Probleme im Transient (Format 2), ReleaseStatus trägt die Matrix
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
710444e88d
commit
c4efeb3ba4
@@ -7,9 +7,13 @@ namespace LIT\MCP\Tests\Unit\Integrations\Divi\Release;
|
||||
use ArrayObject;
|
||||
use Brain\Monkey\Functions;
|
||||
use LIT\MCP\Integrations\Divi\Release\Call;
|
||||
use LIT\MCP\Integrations\Divi\Release\ConstantRequirement;
|
||||
use LIT\MCP\Integrations\Divi\Release\DiviFeature;
|
||||
use LIT\MCP\Integrations\Divi\Release\Manifest;
|
||||
use LIT\MCP\Integrations\Divi\Release\ManifestCheck;
|
||||
use LIT\MCP\Integrations\Divi\Release\Mirror;
|
||||
use LIT\MCP\Integrations\Divi\Release\Problem;
|
||||
use LIT\MCP\Integrations\Divi\Release\SignatureFingerprint;
|
||||
use LIT\MCP\Tests\Unit\TestCase;
|
||||
use RuntimeException;
|
||||
|
||||
@@ -131,4 +135,101 @@ final class ManifestCheckTest extends TestCase
|
||||
ManifestCheck::failed($checks)
|
||||
);
|
||||
}
|
||||
|
||||
/** A manifest with one requirement per problem kind; the default feature is page-read. */
|
||||
private function featureCheck(?\Closure $current = null): ManifestCheck
|
||||
{
|
||||
$manifest = new Manifest(
|
||||
Manifest::PAGES,
|
||||
calls: [
|
||||
new Call('strlen', 1),
|
||||
new Call('str_replace', 3, [DiviFeature::PageWrite]),
|
||||
new Call('trim', 1),
|
||||
new Call('lit_mcp_missing_function', 0, [DiviFeature::PageWrite, DiviFeature::ThemeBuilderWrite]),
|
||||
],
|
||||
constants: [
|
||||
new ConstantRequirement('PHP_VERSION'),
|
||||
new ConstantRequirement('LIT_MCP_MISSING_CONSTANT', [DiviFeature::Catalog]),
|
||||
],
|
||||
postTypes: ['lit_mcp_missing_type'],
|
||||
mirrors: [
|
||||
new Mirror('same', 'a.php', 'a', null, 'gleich'),
|
||||
new Mirror('changed', 'b.php', 'b', null, 'geändert', [DiviFeature::ThemeBuilderWrite]),
|
||||
new Mirror('no-expectation', 'd.php', 'd', null, 'ohne Soll'),
|
||||
],
|
||||
features: [DiviFeature::PageRead]
|
||||
);
|
||||
$hashes = ['same' => 'h1', 'changed' => 'hX', 'no-expectation' => 'h4'];
|
||||
|
||||
return new ManifestCheck(
|
||||
['A' => $manifest],
|
||||
[
|
||||
'same' => 'h1',
|
||||
'changed' => 'h2',
|
||||
'sig:strlen' => (string) SignatureFingerprint::of(new Call('strlen', 1)),
|
||||
'sig:str_replace' => 'a different signature',
|
||||
],
|
||||
$current ?? static fn (Mirror $mirror): ?string => $hashes[$mirror->id] ?? null,
|
||||
static fn (string $name): bool => false
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<Problem> $problems
|
||||
* @return list<array{label: string, kind: string, features: list<string>}>
|
||||
*/
|
||||
private static function rows(array $problems): array
|
||||
{
|
||||
return array_map(static fn (Problem $problem): array => $problem->toArray(), $problems);
|
||||
}
|
||||
|
||||
public function testCodeProblemsNameKindAndFeaturesOfEveryFailedCall(): void
|
||||
{
|
||||
self::assertSame(
|
||||
[
|
||||
['label' => 'Seiten: str_replace() – Signatur geändert', 'kind' => 'signature',
|
||||
'features' => ['page-write']],
|
||||
['label' => 'Seiten: trim() – Referenz der Signatur fehlt', 'kind' => 'reference-missing',
|
||||
'features' => ['page-read']],
|
||||
['label' => 'Seiten: lit_mcp_missing_function()', 'kind' => 'call',
|
||||
'features' => ['page-write', 'tb-write']],
|
||||
['label' => 'Seiten: Konstante LIT_MCP_MISSING_CONSTANT', 'kind' => 'constant',
|
||||
'features' => ['catalog']],
|
||||
],
|
||||
self::rows($this->featureCheck(static function (): never {
|
||||
self::fail('code problems never read Divi files');
|
||||
})->codeProblems())
|
||||
);
|
||||
}
|
||||
|
||||
public function testAMirrorWithoutReferenceIsAMirrorProblemLikeAChangedOne(): void
|
||||
{
|
||||
self::assertSame(
|
||||
[
|
||||
['label' => 'Seiten: Nachbau von b() – geändert', 'kind' => 'mirror', 'features' => ['tb-write']],
|
||||
['label' => 'Seiten: Nachbau von d() – ohne Soll', 'kind' => 'mirror', 'features' => ['page-read']],
|
||||
],
|
||||
self::rows($this->featureCheck()->mirrorProblems())
|
||||
);
|
||||
}
|
||||
|
||||
public function testAnUnreadableMirrorIsAMirrorProblem(): void
|
||||
{
|
||||
$problems = $this->featureCheck(static function (): never {
|
||||
throw new RuntimeException('Divi file gone');
|
||||
})->mirrorProblems();
|
||||
|
||||
self::assertSame(['mirror', 'mirror', 'mirror'], array_column(self::rows($problems), 'kind'));
|
||||
}
|
||||
|
||||
public function testProblemsAreCodeThenMirrorsAndRegistrationIsNone(): void
|
||||
{
|
||||
$check = $this->featureCheck();
|
||||
|
||||
self::assertEquals(array_merge($check->codeProblems(), $check->mirrorProblems()), $check->problems());
|
||||
self::assertNotContains(
|
||||
'Seiten: Post-Typ lit_mcp_missing_type',
|
||||
array_column(self::rows($check->problems()), 'label')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user