/** * Load a engines.json file and parse it into the platforms data array * * @param array $engineData * @param array $json * @param string $engineName * * @return \Browscap\Data\Engine * @throws \RuntimeException if the file does not exist or has invalid JSON */ public function build(array $engineData, array $json, $engineName) { if (!isset($engineData['properties'])) { $engineData['properties'] = array(); } if (array_key_exists('inherits', $engineData)) { $parentName = $engineData['inherits']; if (!isset($json['engines'][$parentName])) { throw new \UnexpectedValueException('parent Engine "' . $parentName . '" is missing for engine "' . $engineName . '"'); } $parentEngine = $this->build($json['engines'][$parentName], $json, $parentName); $parentEngineData = $parentEngine->getProperties(); $inhEngineProperties = $engineData['properties']; foreach ($inhEngineProperties as $name => $value) { if (isset($parentEngineData[$name]) && $parentEngineData[$name] == $value) { throw new \UnexpectedValueException('the value for property "' . $name . '" has the same value in the keys "' . $engineName . '" and its parent "' . $engineData['inherits'] . '"'); } } $engineData['properties'] = array_merge($parentEngineData, $inhEngineProperties); } $engine = new Engine(); $engine->setProperties($engineData['properties']); return $engine; }
/** * tests setter and getter for the engine properties * * @group data * @group sourcetest */ public function testGetProperties() { $properties = array('abc' => 'def'); $object = new Engine($properties); self::assertSame($properties, $object->getProperties()); }
/** * tests setter and getter for the engine properties * * @group data * @group sourcetest */ public function testSetGetProperties() { $properties = array('abc' => 'def'); self::assertSame($this->object, $this->object->setProperties($properties)); self::assertSame($properties, $this->object->getProperties()); }