'Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X)', 'HTTP_ORIGIN' => 'https://agent.example.com', 'HTTP_CF_IPCOUNTRY' => 'CN', 'HTTP_X_IP_REGION' => 'Guangdong', 'HTTP_X_IP_CITY' => 'Shenzhen', ]); $service = new AgentContextService(); $this->assertSame('mobile', $service->device($request)); $this->assertSame('agent.example.com', $service->domain($request)); $this->assertSame([ 'country' => 'CN', 'region' => 'Guangdong', 'city' => 'Shenzhen', ], $service->location($request)); } public function test_desktop_device_falls_back_to_request_host(): void { $request = Request::create('https://api.example.com/agent/auth/login', 'POST', [], [], [], [ 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)', ]); $service = new AgentContextService(); $this->assertSame('pc', $service->device($request)); $this->assertSame('api.example.com', $service->domain($request)); } }