info('=== 两个URS Handler完整功能测试 ==='); $this->info('测试Login4uHandler和Login4ursHandler'); $this->newLine(); try { // 获取测试参数 $userKey = $this->argument('userkey') ?? '$2y$10$vSeIMeziuwcio10eTvLRiuXwSFtSWmVrOqMbewgrbszFfckwmP1bw'; $mobile = $this->argument('mobile') ?? '18600648353'; $password = $this->argument('password') ?? 'a123123'; $this->info("🔑 测试用户密钥: " . substr($userKey, 0, 20) . '...'); $this->info("📱 测试手机号: {$mobile}"); $this->info("🔐 测试密码: " . str_repeat('*', strlen($password))); $this->newLine(); // 测试Login4ursHandler(手机号密码登录) $this->testLogin4ursHandler($mobile, $password); $this->newLine(); // 测试Login4uHandler(也使用手机号密码登录) $this->testLogin4uHandlerWithMobilePassword($mobile, $password); $this->newLine(); $this->info('✅ 两个URS Handler完整功能测试完成'); return 0; } catch (\Exception $e) { $this->error('❌ 测试失败: ' . $e->getMessage()); $this->error('错误详情: ' . $e->getTraceAsString()); return 1; } } /** * 测试Login4uHandler(使用手机号密码) * * @param string $mobile * @param string $password */ protected function testLogin4uHandlerWithMobilePassword(string $mobile, string $password): void { $this->info('🔍 测试Login4uHandler(使用手机号密码静态方法)...'); try { // 使用静态方法处理登录 $loginResult = Login4uHandler::processUrsLoginByMobilePassword($mobile, $password); // 验证响应 $this->info(' 📋 Login4uHandler测试结果:'); $this->info(" ✅ 会话ID: {$loginResult['sessionId']}"); $this->info(" ✅ 农场用户ID: {$loginResult['farmUserId']}"); $this->info(" ✅ URS用户ID: {$loginResult['ursUserId']}"); if (isset($loginResult['user'])) { $user = $loginResult['user']; $this->info(" ✅ 用户名: {$user->username}"); } $this->info(' ✅ Login4uHandler静态方法调用成功'); } catch (\Exception $e) { $this->error(' ❌ Login4uHandler测试失败: ' . $e->getMessage()); throw $e; } } /** * 测试Login4ursHandler * * @param string $mobile * @param string $password */ protected function testLogin4ursHandler(string $mobile, string $password): void { $this->info('🔍 测试Login4ursHandler(使用静态方法)...'); try { // 使用静态方法处理登录 $loginResult = Login4uHandler::processUrsLoginByMobilePassword($mobile, $password); // 验证响应 $this->info(' 📋 Login4ursHandler测试结果:'); $this->info(" ✅ 会话ID: {$loginResult['sessionId']}"); $this->info(" ✅ 农场用户ID: {$loginResult['farmUserId']}"); $this->info(" ✅ URS用户ID: {$loginResult['ursUserId']}"); if (isset($loginResult['user'])) { $user = $loginResult['user']; $this->info(" ✅ 用户名: {$user->username}"); } $this->info(' ✅ Login4ursHandler静态方法调用成功'); } catch (\Exception $e) { $this->error(' ❌ Login4ursHandler测试失败: ' . $e->getMessage()); throw $e; } } }