From c7ccc5ae715698850600071d325742949ccc03c9 Mon Sep 17 00:00:00 2001 From: the_undefined Date: Tue, 9 Sep 2008 21:49:49 +0000 Subject: [PATCH] Added dropTables option to CakeTestCase git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7589 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/tests/lib/cake_test_case.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/cake/tests/lib/cake_test_case.php b/cake/tests/lib/cake_test_case.php index 1ccd0b67a..4b66f482c 100644 --- a/cake/tests/lib/cake_test_case.php +++ b/cake/tests/lib/cake_test_case.php @@ -86,6 +86,13 @@ class CakeTestCase extends UnitTestCase { * @access public */ var $autoFixtures = true; +/** + * Set this to false to avoid tables to be dropped if they already exist˝˝ + * + * @var boolean + * @access public + */ + var $dropTables = true; /** * Maps fixture class names to fixture identifiers as included in CakeTestCase::$fixtures * @@ -364,12 +371,15 @@ class CakeTestCase extends UnitTestCase { $sources = $this->db->listSources(); $this->db->cacheSources = $cacheSources; + if (!$this->dropTables) { + return; + } foreach ($this->_fixtures as $fixture) { if (in_array($fixture->table, $sources)) { $fixture->drop($this->db); + } elseif (!in_array($fixture->table, $sources)) { + $fixture->create($this->db); } - - $fixture->create($this->db); } } } @@ -380,8 +390,10 @@ class CakeTestCase extends UnitTestCase { */ function end() { if (isset($this->_fixtures) && isset($this->db)) { - foreach (array_reverse($this->_fixtures) as $fixture) { - $fixture->drop($this->db); + if ($this->dropTables) { + foreach (array_reverse($this->_fixtures) as $fixture) { + $fixture->drop($this->db); + } } $this->db->sources(true); Configure::write('Cache.disable', false);