Permalink
Browse files

Fix dropTables being ignore in some cases.

When autoFixtures = false & dropTables = false, individually loaded
fixtures should not be dropped.

Fixes #3691
  • Loading branch information...
1 parent f1da6b4 commit 73310f9bfda59c6c2d8927cfbf963ad342bd9cbc @markstory markstory committed Mar 12, 2013
Showing with 8 additions and 3 deletions.
  1. +5 −1 lib/Cake/TestSuite/CakeTestCase.php
  2. +3 −2 lib/Cake/TestSuite/Fixture/CakeFixtureManager.php
View
6 lib/Cake/TestSuite/CakeTestCase.php
@@ -43,7 +43,11 @@
public $autoFixtures = true;
/**
+ * Control table create/drops on each test method.
+ *
* Set this to false to avoid tables to be dropped if they already exist
+ * between each test method. Tables will still be dropped at the
+ * end of each test runner execution.
*
* @var boolean
*/
@@ -205,7 +209,7 @@ public function loadFixtures() {
}
$args = func_get_args();
foreach ($args as $class) {
- $this->fixtureManager->loadSingle($class);
+ $this->fixtureManager->loadSingle($class, null, $this->dropTables);
}
}
View
5 lib/Cake/TestSuite/Fixture/CakeFixtureManager.php
@@ -243,17 +243,18 @@ public function unload(CakeTestCase $test) {
*
* @param string $name of the fixture
* @param DataSource $db DataSource instance or leave null to get DataSource from the fixture
+ * @param boolean $dropTables Whether or not tables should be dropped and re-created.
* @return void
* @throws UnexpectedValueException if $name is not a previously loaded class
*/
- public function loadSingle($name, $db = null) {
+ public function loadSingle($name, $db = null, $dropTables = true) {
$name .= 'Fixture';
if (isset($this->_fixtureMap[$name])) {
$fixture = $this->_fixtureMap[$name];
if (!$db) {
$db = ConnectionManager::getDataSource($fixture->useDbConfig);
}
- $this->_setupTable($fixture, $db);
+ $this->_setupTable($fixture, $db, $dropTables);
$fixture->truncate($db);
$fixture->insert($db);
} else {

0 comments on commit 73310f9

Please sign in to comment.