Author: Thomas Müller (t_mueller_stolzenhain@yahoo.de)
Ejemplo n.º 1
0
 /**
  * tests the creating of an engine factory
  *
  * @group data
  * @group sourcetest
  */
 public function testBuild()
 {
     $engineData = array('abc' => 'def');
     $json = array();
     $engineName = 'Test';
     self::assertInstanceOf('\\Browscap\\Data\\Engine', $this->object->build($engineData, $json, $engineName));
 }
Ejemplo n.º 2
0
 /**
  * Load a engines.json file and parse it into the platforms data array
  *
  * @param string $src Name of the file
  *
  * @throws \RuntimeException             if the file does not exist or has invalid JSON
  * @return \Browscap\Data\DataCollection
  */
 public function addEnginesFile($src)
 {
     $json = $this->loadFile($src);
     if (!isset($json['engines'])) {
         throw new \UnexpectedValueException('required "engines" structure is missing');
     }
     $engineFactory = new Factory\EngineFactory();
     foreach (array_keys($json['engines']) as $engineName) {
         $engineData = $json['engines'][$engineName];
         if (!isset($engineData['properties']) && !isset($engineData['inherits'])) {
             throw new \UnexpectedValueException('required attibute "properties" is missing');
         }
         $this->engines[$engineName] = $engineFactory->build($engineData, $json, $engineName);
     }
     $this->divisionsHaveBeenSorted = false;
     return $this;
 }