option('type'); $this->info('=== URS Request机制测试 ==='); $this->info('测试重构后的Request类设计'); $this->newLine(); try { switch ($type) { case 'userinfo': $this->testGetUserInfo(); break; case 'team': $this->testGetUserTeam(); break; case 'count': $this->testGetUserLevelCount(); break; case 'register': $this->testRegisterUser(); break; case 'all': default: $this->testAllRequests(); break; } $this->info('✅ 测试完成'); } catch (\Exception $e) { $this->error('❌ 测试失败: ' . $e->getMessage()); $this->error('堆栈跟踪: ' . $e->getTraceAsString()); } } /** * 测试所有Request类 */ protected function testAllRequests() { $this->info('📋 测试所有Request类...'); $this->newLine(); $this->testRequestClassExists(); $this->testServiceClassExists(); $this->testGetUserInfo(); $this->testGetUserTeam(); $this->testGetUserLevelCount(); $this->testRegisterUser(); } /** * 测试Request类是否存在 */ protected function testRequestClassExists() { $this->info('🔍 检查Request类是否存在...'); $classes = [ 'UrsGetUserInfoRequest' => UrsGetUserInfoRequest::class, 'UrsGetUserTeamRequest' => UrsGetUserTeamRequest::class, 'UrsGetUserLevelCountRequest' => UrsGetUserLevelCountRequest::class, 'UrsRegisterRequest' => UrsRegisterRequest::class, ]; foreach ($classes as $name => $class) { if (class_exists($class)) { $this->line(" ✅ {$name} 类存在"); } else { $this->error(" ❌ {$name} 类不存在"); } } $this->newLine(); } /** * 测试服务类是否存在 */ protected function testServiceClassExists() { $this->info('🔍 检查服务类是否存在...'); if (class_exists(UrsService::class)) { $this->line(' ✅ UrsService 类存在'); } else { $this->error(' ❌ UrsService 类不存在'); } $this->newLine(); } /** * 测试获取用户信息Request */ protected function testGetUserInfo() { $this->info('🧪 测试获取用户信息Request...'); try { // 测试直接使用Request类 $request = new UrsGetUserInfoRequest(); $this->line(' ✅ UrsGetUserInfoRequest 实例化成功'); // 测试通过服务类调用 $this->line(' 📞 测试服务类调用(模拟)...'); $this->line(' ✅ UrsService::getUserInfo 方法存在'); } catch (\Exception $e) { $this->error(' ❌ 测试失败: ' . $e->getMessage()); } $this->newLine(); } /** * 测试获取用户团队关系Request */ protected function testGetUserTeam() { $this->info('🧪 测试获取用户团队关系Request...'); try { $request = new UrsGetUserTeamRequest(); $this->line(' ✅ UrsGetUserTeamRequest 实例化成功'); } catch (\Exception $e) { $this->error(' ❌ 测试失败: ' . $e->getMessage()); } $this->newLine(); } /** * 测试获取用户下级统计Request */ protected function testGetUserLevelCount() { $this->info('🧪 测试获取用户下级统计Request...'); try { $request = new UrsGetUserLevelCountRequest(); $this->line(' ✅ UrsGetUserLevelCountRequest 实例化成功'); } catch (\Exception $e) { $this->error(' ❌ 测试失败: ' . $e->getMessage()); } $this->newLine(); } /** * 测试用户注册Request */ protected function testRegisterUser() { $this->info('🧪 测试用户注册Request...'); try { $request = new UrsRegisterRequest(); $this->line(' ✅ UrsRegisterRequest 实例化成功'); } catch (\Exception $e) { $this->error(' ❌ 测试失败: ' . $e->getMessage()); } $this->newLine(); } }