Inheritance: extends AbstractProvider
Exemplo n.º 1
0
 public function testRealResultDevice()
 {
     $provider = new UAParser();
     $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' => null, 'version' => ['major' => null, 'minor' => null, 'patch' => null, 'alias' => null, 'complete' => null]], 'operatingSystem' => ['name' => 'iOS', 'version' => ['major' => 5, 'minor' => 0, 'patch' => null, 'alias' => null, 'complete' => '5.0']], 'device' => ['model' => 'iPhone', 'brand' => 'Apple', 'type' => null, 'isMobile' => null, 'isTouch' => null], 'bot' => ['isBot' => null, 'name' => null, 'type' => null]], $result->toArray());
 }
Exemplo n.º 2
0
 /**
  * Device - default value
  */
 public function testParseDeviceDefaultValue()
 {
     $result = $this->getResultMock();
     $result->os->family = 'Windows';
     $result->os->major = 7;
     $result->device->model = 'Feature Phone';
     $result->device->brand = 'Generic';
     $parser = $this->getParser($result);
     $provider = new UAParser($parser);
     $result = $provider->parse('A real user agent...');
     $expectedResult = ['operatingSystem' => ['name' => 'Windows', 'version' => ['major' => 7, 'minor' => null, 'patch' => null, 'alias' => null, 'complete' => '7']], 'device' => ['model' => null, 'brand' => null, 'type' => null, 'isMobile' => null, 'isTouch' => null]];
     $this->assertProviderResult($result, $expectedResult);
 }
 /**
  * Device only
  */
 public function testParseDevice()
 {
     $result = $this->getResultMock();
     $result->device->model = 'iPhone';
     $result->device->brand = 'Apple';
     $parser = $this->getParser($result);
     $provider = new UAParser();
     $provider->setParser($parser);
     $result = $provider->parse('A real user agent...');
     $expectedResult = ['device' => ['model' => 'iPhone', 'brand' => 'Apple', 'type' => null, 'isMobile' => null, 'isTouch' => null]];
     $this->assertProviderResult($result, $expectedResult);
 }