/** * @covers Mage_Selenium_Helper_Data::getDataValue */ public function testGetDataValue() { $instance = new Mage_Selenium_Helper_Data($this->_config); $this->assertInternalType('array', $instance->getDataValue()); $this->assertNotEmpty($instance->getDataValue()); $this->assertFalse($instance->getDataValue('invalid-path')); $this->assertArrayHasKey('generic_admin_user', $instance->getDataValue()); $this->assertInternalType('array', $instance->getDataValue('generic_admin_user')); $this->assertInternalType('string', $instance->getDataValue('generic_admin_user/user_name')); }
/** * Loads test data from DataSet, specified in the $dataSource * * @deprecated * @see loadDataSet() * * @param string $dataSource Data source (e.g. filename in ../data without .yml extension) * @param null|array $override value to override in original data from data source * @param null|array|string $randomize Value to randomize * * @return array */ public function loadData($dataSource, $override = null, $randomize = null) { $data = $this->_dataHelper->getDataValue($dataSource); if (!is_array($data)) { $this->fail('Data \'' . $dataSource . '\' is not loaded'); } array_walk_recursive($data, array($this, 'setDataParams')); if (!empty($randomize)) { $randomize = !is_array($randomize) ? array($randomize) : $randomize; array_walk_recursive($data, array($this, 'randomizeData'), $randomize); } if (!empty($override) && is_array($override)) { $withSubArray = array(); $withOutSubArray = array(); foreach ($override as $key => $value) { if (preg_match('|/|', $key)) { $withSubArray[$key]['subArray'] = preg_replace('#/[a-z0-9_]+$#i', '', $key); $withSubArray[$key]['name'] = preg_replace('#^[a-z0-9_]+/#i', '', $key); $withSubArray[$key]['value'] = $value; } else { $withOutSubArray[$key] = $value; } } foreach ($withOutSubArray as $key => $value) { if (!$this->overrideData($key, $value, $data)) { $data[$key] = $value; } } foreach ($withSubArray as $value) { if (!$this->overrideDataInSubArray($value['subArray'], $value['name'], $value['value'], $data)) { $data[$value['subArray']][$value['name']] = $value['value']; } } } return $data; }