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.
41 lines
2.2 KiB
PHP
41 lines
2.2 KiB
PHP
<?php
|
|
|
|
require dirname(__DIR__) . '/app/Services/Config.php';
|
|
|
|
use App\Services\Config;
|
|
|
|
$System_Config = [
|
|
'db_driver' => 'mysql', 'db_host' => '127.0.0.1:9998', 'db_database' => 'business',
|
|
'db_username' => 'web', 'db_password' => '', 'db_charset' => 'utf8mb4',
|
|
'db_collation' => 'utf8mb4_unicode_ci', 'db_prefix' => '',
|
|
'log_db_host' => '127.0.0.2', 'log_db_port' => '3307', 'log_db_database' => 'metrics',
|
|
'log_db_user' => 'logger', 'log_db_password' => '',
|
|
];
|
|
$assert = static function ($condition, $message) {
|
|
if (!$condition) throw new RuntimeException($message);
|
|
};
|
|
$main = Config::getDbConfig();
|
|
$log = Config::getLogDbConfig();
|
|
$assert($main['host'] === '127.0.0.1' && $main['port'] === 9998, 'Legacy host:port must be parsed separately');
|
|
$assert($log['host'] === '127.0.0.2' && $log['port'] === 3307 && $log['database'] === 'metrics', 'Separate log database lost');
|
|
$System_Config['db_port'] = 3308;
|
|
$assert(Config::getDbConfig()['port'] === 3308, 'Explicit port must take precedence');
|
|
$System_Config['db_host'] = '::1';
|
|
$assert(Config::getDbConfig()['host'] === '::1', 'IPv6 address must not be split as host:port');
|
|
unset($System_Config['db_port']);
|
|
$System_Config['db_host'] = '[::1]:9998';
|
|
$assert(Config::getDbConfig()['host'] === '::1' && Config::getDbConfig()['port'] === 9998, 'Bracketed IPv6 host:port lost');
|
|
$System_Config['log_db_host'] = '';
|
|
$assert(Config::getLogDbConfig()['host'] === 'localhost', 'Empty log host must preserve its local default, not use the business host');
|
|
$System_Config['db_port'] = 0;
|
|
try {
|
|
Config::getDbConfig();
|
|
throw new RuntimeException('Invalid port accepted');
|
|
} catch (InvalidArgumentException $expected) {
|
|
}
|
|
$root = dirname(__DIR__);
|
|
$assert(str_contains(file_get_contents($root . '/bootstrap.php'), "'/config/config.php'"), 'Canonical config.php missing');
|
|
$assert(str_contains(file_get_contents($root . '/config/.config.php.example'), "['cloud_engine_data_dir']"), 'Private engine configuration missing');
|
|
$assert(str_contains(file_get_contents($root . '/config/routes.php'), "'/config/routes_cloud.php'"), 'Cloud API routes not registered');
|
|
echo "Virtualization configuration and separate log database contracts passed.\n";
|