Ejemplo n.º 1
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage There is no device with ID [generic] in the loaded WURFL Data
  */
 public function testShouldNotRebuildTheRepositoryIfAlreadyBuild()
 {
     $logger = new NullLogger();
     $persistenceProvider = new Storage(new Memory());
     $persistenceProvider->setWURFLLoaded(true);
     $userAgentHandlerChain = UserAgentHandlerChainFactory::createFrom($persistenceProvider, $persistenceProvider, $logger);
     $devicePatcher = new DevicePatcher();
     $deviceRepositoryBuilder = new DeviceRepositoryBuilder($persistenceProvider, $userAgentHandlerChain, $devicePatcher, $logger);
     self::assertNotNull($deviceRepositoryBuilder);
     $deviceRepository = $deviceRepositoryBuilder->build(self::WURFL_FILE);
     $deviceRepository->getDevice(WurflConstants::GENERIC);
 }
 /**
  * This method is called before the first test of this test class is run.
  *
  * @since Method available since Release 3.4.0
  */
 public static function setUpBeforeClass()
 {
     $persistenceProvider = new Storage(new Memory());
     $userAgentHandlerChain = UserAgentHandlerChainFactory::createFrom($persistenceProvider, $persistenceProvider);
     $devicePatcher = new DevicePatcher();
     self::$deviceRepositoryBuilder = new DeviceRepositoryBuilder($persistenceProvider, $userAgentHandlerChain, $devicePatcher);
     try {
         self::$deviceRepository = self::$deviceRepositoryBuilder->build(self::RESOURCES_DIR . 'wurfl.xml');
     } catch (Exception $e) {
         echo $e;
     }
 }
 /**
  * This method is called before the first test of this test class is run.
  *
  * @since Method available since Release 3.4.0
  */
 public static function setUpBeforeClass()
 {
     $logger = new NullLogger();
     $persistenceProvider = new Storage(new Memory());
     $userAgentHandlerChain = UserAgentHandlerChainFactory::createFrom($persistenceProvider, $persistenceProvider, $logger);
     $devicePatcher = new DevicePatcher();
     self::$deviceRepositoryBuilder = new DeviceRepositoryBuilder($persistenceProvider, $userAgentHandlerChain, $devicePatcher, $logger);
     try {
         self::$deviceRepository = self::$deviceRepositoryBuilder->build(self::WURFL_FILE);
     } catch (Exception $e) {
         echo $e;
     }
 }
Ejemplo n.º 4
0
 /**
  * return \Wurfl\Handlers\Chain\UserAgentHandlerChain
  */
 private static function initUserAgentHandlerChain()
 {
     $resourcesDir = self::RESOURCES_DIR;
     $cacheDir = self::CACHE_DIR;
     $config = new InMemoryConfig();
     $config->wurflFile($resourcesDir . 'wurfl.xml');
     $params = array(Config::DIR => $cacheDir, Config::EXPIRATION => 0);
     $config->persistence('file', $params);
     $config->cache('memory');
     $cacheStorage = new Storage(new Memory());
     $persistenceStorage = new Storage(new File($params));
     $logger = new NullLogger();
     $UserAgentHandlerChain = UserAgentHandlerChainFactory::createFrom($persistenceStorage, $cacheStorage, $logger);
     return $UserAgentHandlerChain;
 }
Ejemplo n.º 5
0
 /**
  * @return \Wurfl\Handlers\Chain\UserAgentHandlerChain
  */
 private function getUserAgentHandlerChain()
 {
     if (null === $this->userAgentHandlerChain) {
         $this->userAgentHandlerChain = UserAgentHandlerChainFactory::createFrom($this->getPersistenceStorage(), $this->getCacheStorage(), $this->getLogger());
     }
     return $this->userAgentHandlerChain;
 }