mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Implemented CakeTestFixture::truncate, closes #4459
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6951 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
9e79d1768c
commit
fa410d207c
2 changed files with 13 additions and 2 deletions
|
@ -380,7 +380,7 @@ class CakeTestCase extends UnitTestCase {
|
|||
function after($method) {
|
||||
if (isset($this->_fixtures) && isset($this->db) && !in_array(strtolower($method), array('start', 'end'))) {
|
||||
foreach ($this->_fixtures as $fixture) {
|
||||
$this->db->truncate($fixture->table);
|
||||
$fixture->truncate($this->db);
|
||||
}
|
||||
$this->__truncated = true;
|
||||
} else {
|
||||
|
@ -419,7 +419,7 @@ class CakeTestCase extends UnitTestCase {
|
|||
foreach ($args as $class) {
|
||||
if (isset($this->_fixtureClassMap[$class])) {
|
||||
$fixture = $this->_fixtures[$this->_fixtureClassMap[$class]];
|
||||
$this->db->truncate($fixture->table);
|
||||
$fixture->truncate($this->db);
|
||||
$fixture->insert($this->db);
|
||||
} else {
|
||||
trigger_error("Non-existent fixture class {$class} referenced in test", E_USER_WARNING);
|
||||
|
|
|
@ -170,5 +170,16 @@ class CakeTestFixture extends Object {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Truncates the current fixture. Can be overwritten by classes extending CakeFixture to trigger other events before / after
|
||||
* truncate.
|
||||
*
|
||||
* @param object $db A reference to a db instance
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function truncate(&$db) {
|
||||
$db->truncate($this->table);
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Reference in a new issue