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
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $autoFixtures = true;
|
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
|
* Maps fixture class names to fixture identifiers as included in CakeTestCase::$fixtures
|
||||||
*
|
*
|
||||||
|
@ -364,12 +371,15 @@ class CakeTestCase extends UnitTestCase {
|
||||||
$sources = $this->db->listSources();
|
$sources = $this->db->listSources();
|
||||||
$this->db->cacheSources = $cacheSources;
|
$this->db->cacheSources = $cacheSources;
|
||||||
|
|
||||||
|
if (!$this->dropTables) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
foreach ($this->_fixtures as $fixture) {
|
foreach ($this->_fixtures as $fixture) {
|
||||||
if (in_array($fixture->table, $sources)) {
|
if (in_array($fixture->table, $sources)) {
|
||||||
$fixture->drop($this->db);
|
$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() {
|
function end() {
|
||||||
if (isset($this->_fixtures) && isset($this->db)) {
|
if (isset($this->_fixtures) && isset($this->db)) {
|
||||||
foreach (array_reverse($this->_fixtures) as $fixture) {
|
if ($this->dropTables) {
|
||||||
$fixture->drop($this->db);
|
foreach (array_reverse($this->_fixtures) as $fixture) {
|
||||||
|
$fixture->drop($this->db);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$this->db->sources(true);
|
$this->db->sources(true);
|
||||||
Configure::write('Cache.disable', false);
|
Configure::write('Cache.disable', false);
|
||||||
|
|
Loading…
Reference in a new issue