public function testEncodeIsCorrect() { if (!defined('CREDENTIALS_DEVICE_ATLAS_COM_KEY')) { $this->markTestSkipped('no credentials available. Please provide tests/credentials.php'); } $provider = new DeviceAtlasCom($this->getClient(), CREDENTIALS_DEVICE_ATLAS_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()); }
/** * Device only */ public function testParseDevice() { $properties = new stdClass(); $properties->primaryHardwareType = 'mobile'; $rawResult = new stdClass(); $rawResult->properties = $properties; $responseQueue = [new Response(200, ['Content-Type' => 'application/json; charset=UTF-8'], json_encode($rawResult))]; $provider = new DeviceAtlasCom($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); }