You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
2.0 KiB
PHTML
45 lines
2.0 KiB
PHTML
|
1 month ago
|
<?php
|
||
|
|
|
||
|
|
// The account-wide instance cap was retired. Keep this boundary test small
|
||
|
|
// and static so it does not need a database or an engine fixture.
|
||
|
|
$root = dirname(__DIR__);
|
||
|
|
$orderService = file_get_contents($root . '/app/Services/Cloud/CloudOrderService.php');
|
||
|
|
$configExample = file_get_contents($root . '/config/.config.php.example');
|
||
|
|
$schema = file_get_contents($root . '/sql/cloud.sql');
|
||
|
|
$assert = static function ($condition, string $message): void {
|
||
|
|
if (!$condition) {
|
||
|
|
throw new RuntimeException($message);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
$retiredKey = implode('', ['cloud_max_', 'instances_per_user']);
|
||
|
|
$retiredMessage = implode('', ['已达到', '账户虚拟机数量上限']);
|
||
|
|
$assert(is_string($orderService) && is_string($configExample) && is_string($schema),
|
||
|
|
'Account instance-limit contract could not read its source boundaries.');
|
||
|
|
$assert(!str_contains($orderService, $retiredKey)
|
||
|
|
&& !str_contains($orderService, $retiredMessage),
|
||
|
|
'CloudOrderService still contains the retired account-wide instance cap.');
|
||
|
|
$assert(!str_contains($configExample, $retiredKey),
|
||
|
|
'The retired account-wide instance-cap setting remains in the example config.');
|
||
|
|
$assert(!str_contains($schema, $retiredKey)
|
||
|
|
&& str_contains($schema, 'max_instances INT UNSIGNED NOT NULL DEFAULT 0'),
|
||
|
|
'SQL must not add an account cap while retaining host capacity policy.');
|
||
|
|
|
||
|
|
foreach ([$root . '/public', $root . '/resources'] as $directory) {
|
||
|
|
$files = new RecursiveIteratorIterator(
|
||
|
|
new RecursiveDirectoryIterator($directory, FilesystemIterator::SKIP_DOTS)
|
||
|
|
);
|
||
|
|
foreach ($files as $file) {
|
||
|
|
$extension = strtolower($file->getExtension());
|
||
|
|
if (!in_array($extension, ['css', 'js', 'tpl'], true)) {
|
||
|
|
continue;
|
||
|
|
}
|
||
|
|
$contents = file_get_contents($file->getPathname());
|
||
|
|
$assert(is_string($contents) && !str_contains($contents, $retiredKey),
|
||
|
|
'A frontend/template asset still references the retired account cap: '
|
||
|
|
. $file->getPathname());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
echo "Account instance-limit removal contract passed.\n";
|