Browse Source

Fix dropTables being ignore in some cases.

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

Fixes #3691
mark_story 13 years ago
parent
commit
73310f9bfd

+ 5 - 1
lib/Cake/TestSuite/CakeTestCase.php

@@ -43,7 +43,11 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
 	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 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
 		}
 		$args = func_get_args();
 		foreach ($args as $class) {
-			$this->fixtureManager->loadSingle($class);
+			$this->fixtureManager->loadSingle($class, null, $this->dropTables);
 		}
 	}
 

+ 3 - 2
lib/Cake/TestSuite/Fixture/CakeFixtureManager.php

@@ -243,17 +243,18 @@ class CakeFixtureManager {
  *
  * @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 {