From 33d00380ed7e38cb0c586f830e31f0d938acbf11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Renan=20Gon=C3=A7alves?= Date: Tue, 24 May 2011 19:32:38 +0200 Subject: [PATCH] Fixing cross database tests by making sure the fixture was created for the right database. --- lib/Cake/Test/Case/Model/ModelIntegrationTest.php | 3 ++- lib/Cake/TestSuite/Fixture/CakeFixtureManager.php | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php index e9d4c66fa..add528732 100644 --- a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php +++ b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php @@ -399,7 +399,8 @@ class ModelIntegrationTest extends BaseModelTest { $this->assertEqual($TestModel->find('all'), $expected); $db2 = ConnectionManager::getDataSource('test2'); - $this->loadFixtures('User', 'Comment'); + $this->fixtureManager->loadSingle('User', $db2); + $this->fixtureManager->loadSingle('Comment', $db2); $this->assertEqual($TestModel->find('count'), 3); $TestModel->User->setDataSource('test2'); diff --git a/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php b/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php index df1b21e10..b9466c7b4 100644 --- a/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php +++ b/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php @@ -149,12 +149,12 @@ class CakeFixtureManager { * @return void */ protected function _setupTable($fixture, $db = null, $drop = true) { - if (!empty($fixture->created)) { - return; - } if (!$db) { $db = $this->_db; } + if (!empty($fixture->created) && $fixture->created == $db->configKeyName) { + return; + } $cacheSources = $db->cacheSources; $db->cacheSources = false; @@ -165,10 +165,10 @@ class CakeFixtureManager { if ($drop && in_array($table, $sources)) { $fixture->drop($db); $fixture->create($db); - $fixture->created = true; + $fixture->created = $db->configKeyName; } elseif (!in_array($table, $sources)) { $fixture->create($db); - $fixture->created = true; + $fixture->created = $db->configKeyName; } }