/** * Test all Mappings */ public function testAllMappings() { $m1 = new Mapper(); $m1->setMap('browser', $this->confContainer->getMappings()->getBrowser()); $m1->setMap('browser_family', $this->confContainer->getMappings()->getBrowserFamily()); $m1->setMap('desktop_os', $this->confContainer->getMappings()->getDesktopOs()); $m1->setMap('device_brand', $this->confContainer->getMappings()->getDeviceBrand()); $m1->setMap('device_type', $this->confContainer->getMappings()->getDeviceType()); $m1->setMap('os_family', $this->confContainer->getMappings()->getOsFamily()); $m1->setMap('os_short', $this->confContainer->getMappings()->getOsShort()); $this->assertEquals('AB', $m1->getFromInMap(76, 'browser')); $this->assertEquals('Android Browser', $m1->getFromInMap(11, 'browser_family')); $this->assertEquals('IBM', $m1->getFromInMap(6, 'desktop_os')); $this->assertEquals('AC', $m1->getFromInMap(106, 'device_brand')); $this->assertEquals('desktop', $m1->getFromInMap(8, 'device_type')); $this->assertEquals('Android', $m1->getFromInMap(22, 'os_family')); $this->assertEquals('AIX', $m1->getFromInMap(77, 'os_short')); }
/** * Constructor * * @param null $userAgent */ public function __construct($userAgent = null) { $this->confContainer = new ConfContainer(); $yfl = new YamlFileLoader($this->confContainer, new FileLocator($this->getConfigPath())); $loaderResolver = new LoaderResolver(array($yfl)); $delegatingLoader = new DelegatingLoader($loaderResolver); $delegatingLoader->load($this->getConfigFile()); $this->parser = new Parser($this->confContainer); $this->mapper = new Mapper(); $this->mapper->setMap(self::MAP_NAME_BROWSER, $this->confContainer->getMappings()->getBrowser()); $this->mapper->setMap(self::MAP_NAME_BROWSER_FAMILY, $this->confContainer->getMappings()->getBrowserFamily()); $this->mapper->setMap(self::MAP_NAME_DESKTOP_OS, $this->confContainer->getMappings()->getDesktopOs()); $this->mapper->setMap(self::MAP_NAME_DEVICE_BRAND, $this->confContainer->getMappings()->getDeviceBrand()); $this->mapper->setMap(self::MAP_NAME_DEVICE_TYPE, $this->confContainer->getMappings()->getDeviceType()); $this->mapper->setMap(self::MAP_NAME_OS_FAMILY, $this->confContainer->getMappings()->getOsFamily()); $this->mapper->setMap(self::MAP_NAME_OS_SHORT, $this->confContainer->getMappings()->getOsShort()); $this->browser = new Browser(); $this->device = new Device(); $this->os = new Os(); if (!is_null($userAgent)) { $this->setUserAgent($userAgent); } }