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:
the_undefined 2008-05-19 06:29:49 +00:00
parent 9e79d1768c
commit fa410d207c
2 changed files with 13 additions and 2 deletions

View file

@ -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);

View file

@ -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);
}
}
?>