/** * Loads test data. * * @param string $dataFile - File name or full path to file in fixture folder * (for example: 'default\core\Mage\AdminUser\data\AdminUsers') in which DataSet is specified * @param string $dataSource - DataSet name(for example: 'test_data') * or part of DataSet (for example: 'test_data/product') * @param array|null $overrideByKey * @param array|null $overrideByValueParam * * @return array * @throws PHPUnit_Framework_Exception */ public function loadDataSet($dataFile, $dataSource, $overrideByKey = null, $overrideByValueParam = null) { $data = $this->_dataHelper->getDataValue($dataSource); if ($data === false) { $dataSetName = array_shift(explode('/', $dataSource)); $this->_dataHelper->loadTestDataSet($dataFile, $dataSetName); $data = $this->_dataHelper->getDataValue($dataSource); } if (!is_array($data)) { throw new PHPUnit_Framework_Exception('Data "' . $dataSource . '" is not specified.'); } if ($overrideByKey) { foreach ($overrideByKey as $fieldKey => $fieldValue) { if (!$this->overrideDataByCondition($fieldKey, $fieldValue, $data, 'byValueKey')) { throw new PHPUnit_Framework_Exception("Value for '" . $fieldKey . "' field is not changed: [There is no this key in dataset '" . $dataSource . "']"); } } } if ($overrideByValueParam) { foreach ($overrideByValueParam as $fieldKey => $fieldValue) { if (!$this->overrideDataByCondition($fieldKey, $fieldValue, $data, 'byValueParam')) { throw new PHPUnit_Framework_Exception("Value for '" . $fieldKey . "' value parameter is not changed: [There is no this value parameter in dataset '" . $dataSource . "']"); } } } array_walk_recursive($data, array($this, 'setDataParams')); return $this->clearDataArray($data); }
/** * Loads test data. * * @param string $dataFile - File name or full path to file in fixture folder * (for example: 'default\core\Mage\AdminUser\data\AdminUsers') in which DataSet is specified * @param string $dataSource - DataSet name(for example: 'test_data') * or part of DataSet (for example: 'test_data/product') * @param array|null $overrideByKey * @param array|null $overrideByValueParam * * @throws PHPUnit_Framework_Exception * @return array */ public function loadDataSet($dataFile, $dataSource, $overrideByKey = null, $overrideByValueParam = null) { $data = $this->_dataHelper->getDataValue($dataSource); if ($data === false) { $explodedData = explode('/', $dataSource); $dataSetName = array_shift($explodedData); $this->_dataHelper->loadTestDataSet($dataFile, $dataSetName); $data = $this->_dataHelper->getDataValue($dataSource); } if (!is_array($data)) { throw new PHPUnit_Framework_Exception('Data "' . $dataSource . '" is not specified.'); } if ($overrideByKey) { $data = $this->overrideArrayData($overrideByKey, $data, 'byFieldKey'); } if ($overrideByValueParam) { $data = $this->overrideArrayData($overrideByValueParam, $data, 'byValueParam'); } array_walk_recursive($data, array($this, 'setDataParams')); return $this->clearDataArray($data); }
/** * @covers Mage_Selenium_Helper_Data::loadTestDataSet */ public function testLoadTestDataSetNoDataset() { $instance = new Mage_Selenium_Helper_Data($this->_config); $this->setExpectedException('RuntimeException', 'DataSet with name "not_existing_dataset" is not present'); $instance->loadTestDataSet('default\\core\\Mage\\UnitTest\\data\\UnitTestsData', 'not_existing_dataset'); }