From fa410d207ccedc9ee8c9c5b155a87978aad31ce0 Mon Sep 17 00:00:00 2001 From: the_undefined Date: Mon, 19 May 2008 06:29:49 +0000 Subject: [PATCH] Implemented CakeTestFixture::truncate, closes #4459 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6951 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/tests/lib/cake_test_case.php | 4 ++-- cake/tests/lib/cake_test_fixture.php | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cake/tests/lib/cake_test_case.php b/cake/tests/lib/cake_test_case.php index 5e0c37aa9..8c45ad771 100644 --- a/cake/tests/lib/cake_test_case.php +++ b/cake/tests/lib/cake_test_case.php @@ -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); diff --git a/cake/tests/lib/cake_test_fixture.php b/cake/tests/lib/cake_test_fixture.php index 47a6d827a..01d6dfb4f 100644 --- a/cake/tests/lib/cake_test_fixture.php +++ b/cake/tests/lib/cake_test_fixture.php @@ -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); + } } ?> \ No newline at end of file