mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Added dropTables option to CakeTestCase
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7589 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
bfa180e4af
commit
c7ccc5ae71
1 changed files with 16 additions and 4 deletions
|
@ -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,15 +371,18 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Runs as last test to drop tables.
|
||||
*
|
||||
|
@ -380,9 +390,11 @@ class CakeTestCase extends UnitTestCase {
|
|||
*/
|
||||
function end() {
|
||||
if (isset($this->_fixtures) && isset($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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue