agent foundation
This commit is contained in:
@@ -41,6 +41,9 @@ class CoreStarterkitContractTest extends TestCase
|
||||
'/\$_GET/' => '$_GET',
|
||||
'/\$_FILES/' => '$_FILES',
|
||||
'/REQUEST_METHOD/' => 'REQUEST_METHOD',
|
||||
'/\$_SESSION/' => '$_SESSION',
|
||||
'/\$_SERVER/' => '$_SERVER',
|
||||
'/\$_COOKIE/' => '$_COOKIE',
|
||||
];
|
||||
|
||||
foreach ($patterns as $pattern => $label) {
|
||||
@@ -49,29 +52,30 @@ class CoreStarterkitContractTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function testServicesDoNotUseSuperglobals(): void
|
||||
{
|
||||
$patterns = [
|
||||
'/\$_POST/' => '$_POST',
|
||||
'/\$_GET/' => '$_GET',
|
||||
'/\$_FILES/' => '$_FILES',
|
||||
'/\$_SERVER/' => '$_SERVER',
|
||||
'/\$_COOKIE/' => '$_COOKIE',
|
||||
'/\$_SESSION/' => '$_SESSION',
|
||||
'/\$_REQUEST/' => '$_REQUEST',
|
||||
];
|
||||
|
||||
foreach ($patterns as $pattern => $label) {
|
||||
$violations = $this->findPatternMatchesInPhpFiles('lib/Service', $pattern);
|
||||
$this->assertSame([], $violations, "Superglobal {$label} usage found in lib/Service/:\n" . implode("\n", $violations));
|
||||
}
|
||||
}
|
||||
|
||||
public function testApiPagesDoNotReadJsonBodyDirectly(): void
|
||||
{
|
||||
$violations = $this->findPatternMatchesInPhpFiles('pages/api/v1', '/ApiResponse::readJsonBody\s*\(/');
|
||||
$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)/';
|
||||
@@ -108,6 +112,34 @@ class CoreStarterkitContractTest extends TestCase
|
||||
$this->assertSame([], $violations, "asset(...) JS URLs found in templates/pages:\n" . implode("\n", $violations));
|
||||
}
|
||||
|
||||
public function testNoLegacySettingsGatewayOrServiceReferencesExist(): void
|
||||
{
|
||||
$patterns = [
|
||||
'/\bSettingService::class\b/' => 'SettingService::class',
|
||||
'/\bSettingGateway::class\b/' => 'SettingGateway::class',
|
||||
'/\bnew\s+SettingService\s*\(/' => 'new SettingService(...)',
|
||||
'/\bnew\s+SettingGateway\s*\(/' => 'new SettingGateway(...)',
|
||||
'/use\s+[^;]*\\\\SettingService;/' => 'use ...\\SettingService',
|
||||
'/use\s+[^;]*\\\\SettingGateway;/' => 'use ...\\SettingGateway',
|
||||
];
|
||||
|
||||
foreach ($patterns as $pattern => $label) {
|
||||
$violations = array_merge(
|
||||
$this->findPatternMatchesInPhpFiles('lib', $pattern),
|
||||
$this->findPatternMatchesInPhpFiles('pages', $pattern),
|
||||
$this->findPatternMatchesInPhpFiles('tests', $pattern),
|
||||
);
|
||||
$violations = array_values(array_filter(
|
||||
$violations,
|
||||
static fn (string $path): bool => $path !== 'tests/Architecture/CoreStarterkitContractTest.php'
|
||||
));
|
||||
$violations = array_values(array_unique($violations));
|
||||
sort($violations);
|
||||
|
||||
$this->assertSame([], $violations, "Legacy settings reference {$label} found:\n" . implode("\n", $violations));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user