From a194f6a25e8695752008aaa33fe283ffc69db38f Mon Sep 17 00:00:00 2001 From: "mariano.iglesias" Date: Wed, 12 Nov 2008 23:04:05 +0000 Subject: [PATCH] Simplifying parameter parsing when importing structure / records from a fixture. Flushing registry after processing import so related models DB config remain unchanged git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7870 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/tests/lib/cake_test_fixture.php | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/cake/tests/lib/cake_test_fixture.php b/cake/tests/lib/cake_test_fixture.php index 3ead38333..46ae26404 100644 --- a/cake/tests/lib/cake_test_fixture.php +++ b/cake/tests/lib/cake_test_fixture.php @@ -64,27 +64,15 @@ class CakeTestFixture extends Object { */ function init() { if (isset($this->import) && (is_string($this->import) || is_array($this->import))) { - $import = array(); + $import = array_merge(array('connection' => 'default', 'records' => false), is_array($this->import) ? $this->import : array('model' => $this->import)); - if (is_string($this->import) || is_array($this->import) && isset($this->import['model'])) { - $import = array_merge(array('connection' => 'default', 'records' => false), is_array($this->import) ? $this->import : array()); - $import['model'] = is_array($this->import) ? $this->import['model'] : $this->import; - } elseif (isset($this->import['table'])) { - $import = array_merge(array('connection' => 'default', 'records' => false), $this->import); - } - - if (isset($import['model']) && (class_exists($import['model']) || App::import('Model', $import['model']))) { - $connection = isset($import['connection']) - ? $import['connection'] - : 'default'; - ClassRegistry::config(array('ds' => $connection)); - $model =& ClassRegistry::init($import['model']); + if (isset($import['model']) && App::import('Model', $import['model'])) { + $model =& ClassRegistry::init(array('class' => $import['model'], 'ds' => $import['connection'])); $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::removeObject($model->alias); + ClassRegistry::flush(); } elseif (isset($import['table'])) { $model =& new Model(null, $import['table'], $import['connection']); $db =& ConnectionManager::getDataSource($import['connection']);