/** * Device only */ public function testParseDevice() { $parser = $this->getParser(); $parser->expects($this->any())->method('getClient')->will($this->returnValue([])); $parser->expects($this->any())->method('getOs')->will($this->returnValue([])); $parser->expects($this->any())->method('getDevice')->will($this->returnValue(1)); $parser->expects($this->any())->method('getModel')->will($this->returnValue('iPhone')); $parser->expects($this->any())->method('getBrandName')->will($this->returnValue('Apple')); $parser->expects($this->any())->method('getDeviceName')->will($this->returnValue('smartphone')); $parser->expects($this->any())->method('isMobile')->will($this->returnValue(true)); $parser->expects($this->any())->method('isTouchEnabled')->will($this->returnValue(true)); $provider = new PiwikDeviceDetector($parser); $result = $provider->parse('A real user agent...'); $expectedResult = ['device' => ['model' => 'iPhone', 'brand' => 'Apple', 'type' => 'smartphone', 'isMobile' => true, 'isTouch' => true]]; $this->assertProviderResult($result, $expectedResult); }
public function testRealResultDevice() { $provider = new PiwikDeviceDetector(); $result = $provider->parse('Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3'); $this->assertEquals(['browser' => ['name' => 'Mobile Safari', 'version' => ['major' => 5, 'minor' => 1, 'patch' => null, 'alias' => null, 'complete' => '5.1']], 'renderingEngine' => ['name' => 'WebKit', 'version' => ['major' => null, 'minor' => null, 'patch' => null, 'alias' => null, 'complete' => null]], 'operatingSystem' => ['name' => 'iOS', 'version' => ['major' => 5, 'minor' => null, 'patch' => null, 'alias' => null, 'complete' => '5.0']], 'device' => ['model' => 'iPhone', 'brand' => 'Apple', 'type' => 'smartphone', 'isMobile' => true, 'isTouch' => null], 'bot' => ['isBot' => null, 'name' => null, 'type' => null]], $result->toArray()); }