Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 54f4733

Browse files
author
Michael Grauer
committed
ENH: refs #258. changed loadData function to allow filename and model modules.
Before this fix, it was not possible to have a test xml dataset in modules that had core models. This fix allows calling loadData with both a fileModule, which can specify the module that the data file came from, and a modelModule param, which can specify the module that the model came from. E.g. loadData('User','default','','batchmake'); would load a file default.xml defined in the batchmake module that has User models from the core defined in it, with this command loading those users. loadData('Itemmetric','default','batchmake','batchmake'); would load a file default.xml defined in the batchmake module that has Itemmetric models defined in the batchmake module, with this command loading those itemmetrics.
1 parent 21c4581 commit 54f4733

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tests/DatabaseTestCase.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,20 @@ protected function getDataSet($name = 'default', $module = null)
134134
return $this->createFlatXmlDataSet($path);
135135
}
136136

137-
/** loadData */
138-
protected function loadData($modelName, $file = null, $module = '')
137+
/** loadData
138+
* @param modelName of model to load
139+
* @param file that the test data is defined in
140+
* @param modelModule the module of the model, or '' if in core
141+
* @param fileModule the module the test data file is in, or '' if in core
142+
*/
143+
protected function loadData($modelName, $file = null, $modelModule = '', $fileModule = '')
139144
{
140-
$model = $this->ModelLoader->loadModel($modelName, $module);
145+
$model = $this->ModelLoader->loadModel($modelName, $modelModule);
141146
if($file == null)
142147
{
143148
$file = strtolower($modelName);
144149
}
145-
146-
$data = $this->getDataSet($file, $module);
150+
$data = $this->getDataSet($file, $fileModule);
147151
$dataUsers = $data->getTable($model->getName());
148152
$rows = $dataUsers->getRowCount();
149153
$key = array();

0 commit comments

Comments
 (0)