/** * Device only */ public function testParseDevice() { $data = new stdClass(); $data->platform_type = 'mobile'; $rawResult = new stdClass(); $rawResult->data = $data; $responseQueue = [new Response(200, ['Content-Type' => 'application/json'], json_encode($rawResult))]; $provider = new UserAgentApiCom($this->getClient($responseQueue), 'apiKey123'); $result = $provider->parse('A real user agent...'); $expectedResult = ['device' => ['model' => null, 'brand' => null, 'type' => 'mobile', 'isMobile' => null, 'isTouch' => null]]; $this->assertProviderResult($result, $expectedResult); }
public function testEncodeIsCorrect() { if (!defined('CREDENTIALS_USER_AGENT_API_COM_KEY')) { $this->markTestSkipped('no credentials available. Please provide tests/credentials.php'); } $provider = new UserAgentApiCom($this->getClient(), CREDENTIALS_USER_AGENT_API_COM_KEY); $userAgent = 'Mozilla/5.0 (Linux; U; Android 3.0.1; en-us; HTC T9299+ For AT&T Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'; $result = $provider->parse($userAgent); $this->assertEquals('WebKit', $result->getRenderingEngine()->getName()); }