Fixing missing table errors on model imports. Fixed broken test. Fixes #5877

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7916 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mark_story 2008-12-11 19:16:02 +00:00
parent 43af288eca
commit 3682c9c6ae
2 changed files with 4 additions and 3 deletions

View file

@ -201,7 +201,7 @@ class CakeTestFixtureTest extends CakeTestCase {
$Fixture =& new CakeTestFixtureDefaultImportFixture();
$Fixture->fields = $Fixture->records = null;
$Fixture->import = 'FixtureImportTestModel';
$Fixture->import = array('model' => 'FixtureImportTestModel', 'connection' => 'new_test_suite');
$Fixture->init();
$this->assertEqual(array_keys($Fixture->fields), array('id', 'name', 'created'));

View file

@ -67,11 +67,13 @@ class CakeTestFixture extends Object {
$import = array_merge(array('connection' => 'default', 'records' => false), is_array($this->import) ? $this->import : array('model' => $this->import));
if (isset($import['model']) && App::import('Model', $import['model'])) {
$model =& ClassRegistry::init(array('class' => $import['model'], 'ds' => $import['connection']));
ClassRegistry::config(array('ds' => $import['connection']));
$model =& ClassRegistry::init($import['model']);
$db =& ConnectionManager::getDataSource($model->useDbConfig);
$db->cacheSources = false;
$this->fields = $model->schema(true);
$this->fields[$model->primaryKey]['key'] = 'primary';
ClassRegistry::config(array('ds' => 'test_suite'));
ClassRegistry::flush();
} elseif (isset($import['table'])) {
$model =& new Model(null, $import['table'], $import['connection']);
@ -86,7 +88,6 @@ class CakeTestFixture extends Object {
if (isset($import['records']) && $import['records'] !== false && isset($model) && isset($db)) {
$this->records = array();
$query = array(
'fields' => array_keys($this->fields),
'table' => $db->fullTableName($model->table),