assertAssetVersionUsed('templates'); } public function testCorePageAssetReferencesUseAssetVersion(): void { $this->assertAssetVersionUsed('pages'); } public function testModulePageAssetReferencesUseAssetVersion(): void { $root = $this->projectRootPath(); $modulesDir = $root . '/modules'; if (!is_dir($modulesDir)) { self::markTestSkipped('modules/ directory missing.'); } foreach (scandir($modulesDir) ?: [] as $entry) { if ($entry === '.' || $entry === '..' || !is_dir($modulesDir . '/' . $entry)) { continue; } foreach (['pages', 'templates'] as $subdir) { $rel = 'modules/' . $entry . '/' . $subdir; if (is_dir($root . '/' . $rel)) { $this->assertAssetVersionUsed($rel); } } } } private function assertAssetVersionUsed(string $relativeDirectory): void { $jsViolations = $this->findPatternMatchesInFiles($relativeDirectory, self::BARE_JS_PATTERN, ['phtml']); $cssViolations = $this->findPatternMatchesInFiles($relativeDirectory, self::BARE_CSS_PATTERN, ['phtml']); $violations = array_unique(array_merge($jsViolations, $cssViolations)); sort($violations); self::assertSame( [], $violations, "Asset references must use assetVersion() for cache-busting. Violations:\n" . implode("\n", $violations) ); } }