feat: Signatur-Fingerabdruck der Divi-Aufrufe (Reflection); fingerprints.json enthält sig:-Einträge, divi-check --update-reference schreibt sie; Referenz für Divi 5.15.1

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Jan-Niclas Loosen
2026-10-18 22:01:56 +02:00
co-authored by Claude Sonnet 5.5
parent 392fe7c569
commit 710444e88d
8 changed files with 525 additions and 20 deletions
+42 -4
View File
@@ -13,6 +13,7 @@ use LIT\MCP\Integrations\Divi\Release\CompatibilityCheck;
use LIT\MCP\Integrations\Divi\Release\DiviReference;
use LIT\MCP\Tests\Unit\TestCase;
use Mockery;
use RuntimeException;
final class DiviCheckCommandTest extends TestCase
{
@@ -23,10 +24,18 @@ final class DiviCheckCommandTest extends TestCase
private string $sourceDir = '';
private string $expectedFile = '';
/** @var array<string, string> What the command reads as the signatures of the running Divi. */
private array $signatures = [];
/** Set to true to make the signature read fail like a Divi call that is not loaded. */
private bool $signaturesUnreadable = false;
protected function setUp(): void
{
parent::setUp();
$this->lines = [];
$this->signatures = ['sig:et_pb_is_allowed' => str_repeat('a', 64), 'sig:A::b' => str_repeat('b', 64)];
$this->signaturesUnreadable = false;
$base = sys_get_temp_dir() . '/lit-cli-' . uniqid();
$this->themeDir = $base . '/Divi';
$this->sourceDir = $base . '/reference';
@@ -75,7 +84,14 @@ final class DiviCheckCommandTest extends TestCase
},
fn (): ?string => $this->themeDir,
$this->expectedFile,
$noSourceDir ? static fn (): ?string => null : fn (): ?string => $this->sourceDir
$noSourceDir ? static fn (): ?string => null : fn (): ?string => $this->sourceDir,
function (): array {
if ($this->signaturesUnreadable) {
throw new RuntimeException('signature of et_pb_is_allowed(): symbol is not loaded');
}
return $this->signatures;
}
);
}
@@ -176,7 +192,24 @@ final class DiviCheckCommandTest extends TestCase
}
}
public function testUpdateReferenceWritesFingerprintsAndSources(): void
public function testUpdateReferenceWritesNothingWhenASignatureIsUnreadable(): void
{
$this->writeDivi();
$this->signaturesUnreadable = true;
$code = $this->command([CheckStep::MIRRORS => ['geändert']])->run(['update-reference' => true]);
self::assertSame(1, $code);
self::assertStringContainsString(
'Referenz nicht aktualisiert – die Signatur eines Divi-Aufrufs ist nicht lesbar: '
. 'signature of et_pb_is_allowed(): symbol is not loaded',
implode("\n", $this->lines)
);
self::assertFileDoesNotExist($this->expectedFile, 'all or nothing');
self::assertSame([], glob($this->sourceDir . '/*.txt'), 'no source written either');
}
public function testUpdateReferenceWritesFingerprintsSignaturesAndSources(): void
{
$this->writeDivi();
@@ -185,11 +218,16 @@ final class DiviCheckCommandTest extends TestCase
self::assertSame(0, $code);
self::assertSame(
[
'library-submit-layout', 'preset-sync', 'tb-api-save', 'tb-load-setting-options', 'tb-store-template',
'vb-sync-flags',
'library-submit-layout', 'preset-sync', 'sig:A::b', 'sig:et_pb_is_allowed', 'tb-api-save',
'tb-load-setting-options', 'tb-store-template', 'vb-sync-flags',
],
array_keys(DiviReference::expected($this->expectedFile))
);
self::assertSame(str_repeat('b', 64), DiviReference::expected($this->expectedFile)['sig:A::b']);
self::assertContains(
'Referenz aktualisiert (6 Fingerabdrücke, 2 Signaturen). Smoke-Skripte laufen lassen, dann committen.',
$this->lines
);
self::assertStringStartsWith(
'function et_pb_submit_layout(',
(string) DiviReference::readSource('library-submit-layout', $this->sourceDir)