diff --git a/cake/tests/lib/cake_test_case.php b/cake/tests/lib/cake_test_case.php index 7b3161d10..123f5484b 100644 --- a/cake/tests/lib/cake_test_case.php +++ b/cake/tests/lib/cake_test_case.php @@ -162,7 +162,7 @@ class CakeTestCase extends UnitTestCase { foreach ($classRegistry->__map as $key => $name) { $object =& $classRegistry->getObject(Inflector::camelize($key)); if (is_subclass_of($object, 'Model') && ((is_array($params['fixturize']) && in_array($object->alias, $params['fixturize'])) || $params['fixturize'] === true)) { - $models[$object->alias] = array ( + $models[$object->alias] = array( 'table' => $object->table, 'model' => $object->alias, 'key' => Inflector::camelize($key)); @@ -173,7 +173,8 @@ class CakeTestCase extends UnitTestCase { $this->_queries = array( 'create' => array(), 'insert' => array(), - 'drop' => array()); + 'drop' => array() + ); foreach ($models as $model) { $fixture =& new CakeTestFixture($this->db); @@ -374,10 +375,12 @@ class CakeTestCase extends UnitTestCase { $this->db->cacheSources = false; $sources = $this->db->listSources(); $this->db->cacheSources = $cacheSources; + foreach ($this->_fixtures as $fixture) { if (in_array($fixture->table, $sources)) { $fixture->drop($this->db); } + $fixture->create($this->db); } } diff --git a/cake/tests/lib/cake_test_fixture.php b/cake/tests/lib/cake_test_fixture.php index 457891d6a..9c9dd9e13 100644 --- a/cake/tests/lib/cake_test_fixture.php +++ b/cake/tests/lib/cake_test_fixture.php @@ -55,7 +55,7 @@ class CakeTestFixture extends Object { */ function __construct(&$db) { App::import('Model', 'Schema'); - $this->Schema = new CakeSchema(array('name'=>'TestSuite', 'connection'=>'test_suite')); + $this->Schema = new CakeSchema(array('name' => 'TestSuite', 'connection' => 'test_suite')); $this->init(); } @@ -79,6 +79,7 @@ class CakeTestFixture extends Object { if (isset($import['model']) && (class_exists($import['model']) || App::import('Model', $import['model']))) { $model =& new $import['model']; + $db =& ConnectionManager::getDataSource($model->useDbConfig); $db->cacheSources = false; $this->fields = $model->schema(true);