info('=== Mex配置功能测试 ==='); // 测试基本配置获取 $this->info('1. 测试基本配置获取:'); $systemEnabled = MexConfigService::get('system.enabled'); $this->line("system.enabled = {$systemEnabled}"); $maintenanceMode = MexConfigService::get('system.maintenance_mode'); $this->line("system.maintenance_mode = {$maintenanceMode}"); // 测试类型化获取 $this->info('2. 测试类型化获取:'); $isSystemEnabled = MexConfigService::getBool('system.enabled'); $this->line("isSystemEnabled (bool) = " . ($isSystemEnabled ? 'true' : 'false')); $maxOrderAmount = MexConfigService::getFloat('trading.max_order_amount'); $this->line("maxOrderAmount (float) = {$maxOrderAmount}"); $maxOrderQuantity = MexConfigService::getInt('trading.max_order_quantity'); $this->line("maxOrderQuantity (int) = {$maxOrderQuantity}"); // 测试业务快捷方法 $this->info('3. 测试业务快捷方法:'); $this->line("isSystemEnabled() = " . (MexConfigService::isSystemEnabled() ? 'true' : 'false')); $this->line("isMaintenanceMode() = " . (MexConfigService::isMaintenanceMode() ? 'true' : 'false')); $this->line("isBuyAllowed() = " . (MexConfigService::isBuyAllowed() ? 'true' : 'false')); $this->line("isSellAllowed() = " . (MexConfigService::isSellAllowed() ? 'true' : 'false')); $this->line("isMatchingEnabled() = " . (MexConfigService::isMatchingEnabled() ? 'true' : 'false')); // 测试配置修改 $this->info('4. 测试配置修改:'); $oldValue = MexConfigService::get('system.debug_mode'); $this->line("debug_mode 原值: {$oldValue}"); $result = MexConfigService::set('system.debug_mode', '1'); $this->line("设置 debug_mode = 1: " . ($result ? '成功' : '失败')); $newValue = MexConfigService::get('system.debug_mode'); $this->line("debug_mode 新值: {$newValue}"); // 恢复原值 MexConfigService::set('system.debug_mode', $oldValue); $this->line("已恢复原值"); // 测试配置验证 $this->info('5. 测试配置验证:'); $validation = MexConfigService::validateValue('trading.min_order_amount', '0.01'); $this->line("验证 min_order_amount = 0.01: " . ($validation['valid'] ? '有效' : '无效')); $validation = MexConfigService::validateValue('trading.min_order_amount', 'invalid'); $this->line("验证 min_order_amount = invalid: " . ($validation['valid'] ? '有效' : '无效')); // 测试配置存在性检查 $this->info('6. 测试配置存在性:'); $exists = MexConfigService::exists('system.enabled'); $this->line("system.enabled 存在: " . ($exists ? '是' : '否')); $exists = MexConfigService::exists('non.existent.config'); $this->line("non.existent.config 存在: " . ($exists ? '是' : '否')); $this->info('=== 测试完成 ==='); } }