1
0
Files
breadcrumb-the-shire/tests/Architecture/SecurityLoggingRuntimeContractTest.php
fs e10b1215da fix(audit): restructure module pages to avoid admin/ path collision
Module pages must use a unique top-level directory (audit/) instead of
nesting under admin/ which collides with core's pages/admin/ during
module:build symlink creation. Routes still map admin/* URLs to the
audit/ page directory via manifest route targets.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 08:13:37 +01:00

41 lines
1.5 KiB
PHP

<?php
namespace MintyPHP\Tests\Architecture;
use PHPUnit\Framework\TestCase;
final class SecurityLoggingRuntimeContractTest extends TestCase
{
use ProjectFileAssertionSupport;
public function testFrontendTelemetryIngestUsesOnlyRequestScopedErrorLogFallback(): void
{
$violations = array_merge(
$this->findPatternMatchesInPhpFiles('lib', '/\berror_log\s*\(/'),
$this->findPatternMatchesInPhpFiles('pages', '/\berror_log\s*\(/'),
$this->findPatternMatchesInPhpFiles('modules', '/\berror_log\s*\(/')
);
sort($violations);
self::assertSame(
['modules/audit/pages/audit/frontend-telemetry/ingest().php'],
$violations,
"Unexpected error_log() usage outside the telemetry ingest fallback:\n" . implode("\n", $violations)
);
$content = $this->readProjectFile('modules/audit/pages/audit/frontend-telemetry/ingest().php');
self::assertStringContainsString(
"error_log('[frontend-telemetry] ingest record_failed request_id=' . RequestContext::id());",
$content
);
preg_match('/^.*\berror_log\s*\(.*$/m', $content, $matches);
$errorLogLine = $matches[0] ?? '';
self::assertNotSame('', $errorLogLine, 'Expected a dedicated telemetry error_log() fallback line.');
self::assertStringNotContainsString('$payload', $errorLogLine);
self::assertStringNotContainsString('$record', $errorLogLine);
self::assertStringNotContainsString('$events', $errorLogLine);
}
}