Repo Interface für tests
This commit is contained in:
@@ -55,10 +55,72 @@ class CoreStarterkitContractTest extends TestCase
|
||||
$this->assertSame([], $violations, "ApiResponse::readJsonBody usage found in pages/api/v1/:\n" . implode("\n", $violations));
|
||||
}
|
||||
|
||||
public function testLegacyAndTemplateModulesAreRemoved(): void
|
||||
{
|
||||
$root = $this->projectRootPath();
|
||||
$this->assertFileDoesNotExist(
|
||||
$root . '/web/js/components/app-filter-overflow.js',
|
||||
'Legacy filter overflow module must remain removed.'
|
||||
);
|
||||
$this->assertFileDoesNotExist(
|
||||
$root . '/web/js/components/app-toggle-toolbar.js',
|
||||
'Legacy toolbar toggle module must remain removed.'
|
||||
);
|
||||
$this->assertFileDoesNotExist(
|
||||
$root . '/web/js/components/_template.js',
|
||||
'Component template module must remain removed from production JS path.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testTemplatesDoNotUseLegacyFilterToggleMarkup(): void
|
||||
{
|
||||
$pattern = '/data-(?:toolbar-toggle|filter-overflow|filter-toggle)/';
|
||||
$violations = array_merge(
|
||||
$this->findPatternMatchesInFiles('templates', $pattern, ['phtml']),
|
||||
$this->findPatternMatchesInFiles('pages', $pattern, ['phtml'])
|
||||
);
|
||||
sort($violations);
|
||||
|
||||
$this->assertSame([], $violations, "Legacy filter toggle markup found in templates/pages:\n" . implode("\n", $violations));
|
||||
}
|
||||
|
||||
public function testPagesAndTemplatesDoNotUseInlineModuleScripts(): void
|
||||
{
|
||||
$pattern = '/<script\b(?=[^>]*\btype=["\']module["\'])(?![^>]*\bsrc=)[^>]*>/i';
|
||||
$violations = array_merge(
|
||||
$this->findPatternMatchesInFiles('templates', $pattern, ['phtml']),
|
||||
$this->findPatternMatchesInFiles('pages', $pattern, ['phtml'])
|
||||
);
|
||||
sort($violations);
|
||||
|
||||
$this->assertSame([], $violations, "Inline module scripts found in templates/pages:\n" . implode("\n", $violations));
|
||||
}
|
||||
|
||||
public function testPagesAndTemplatesUseAssetVersionForJsUrls(): void
|
||||
{
|
||||
$pattern = '/asset\(\s*[\'"][^\'"]+\.js/i';
|
||||
$violations = array_merge(
|
||||
$this->findPatternMatchesInFiles('templates', $pattern, ['phtml']),
|
||||
$this->findPatternMatchesInFiles('pages', $pattern, ['phtml'])
|
||||
);
|
||||
sort($violations);
|
||||
|
||||
$this->assertSame([], $violations, "asset(...) JS URLs found in templates/pages:\n" . implode("\n", $violations));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
private function findPatternMatchesInPhpFiles(string $relativeDirectory, string $pattern): array
|
||||
{
|
||||
return $this->findPatternMatchesInFiles($relativeDirectory, $pattern, ['php']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $extensions
|
||||
* @return list<string>
|
||||
*/
|
||||
private function findPatternMatchesInFiles(string $relativeDirectory, string $pattern, array $extensions): array
|
||||
{
|
||||
$root = $this->projectRootPath();
|
||||
$basePath = $root . '/' . $relativeDirectory;
|
||||
@@ -69,7 +131,7 @@ class CoreStarterkitContractTest extends TestCase
|
||||
|
||||
/** @var \SplFileInfo $file */
|
||||
foreach ($iterator as $file) {
|
||||
if (!$file->isFile() || $file->getExtension() !== 'php') {
|
||||
if (!$file->isFile() || !in_array($file->getExtension(), $extensions, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user