Adding fix to only create fixture records if the table has been truncated

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5914 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-10-28 19:42:16 +00:00
parent 7e9b05e429
commit e1a0f554e1

View file

@ -73,6 +73,7 @@ class CakeTestCase extends UnitTestCase {
* @access private * @access private
*/ */
var $methods = array('start', 'end', 'startcase', 'endcase', 'starttest', 'endtest'); var $methods = array('start', 'end', 'startcase', 'endcase', 'starttest', 'endtest');
var $__truncated = true;
/** /**
* Called when a test case (group of methods) is about to start (to be overriden when needed.) * Called when a test case (group of methods) is about to start (to be overriden when needed.)
* *
@ -308,7 +309,7 @@ class CakeTestCase extends UnitTestCase {
} }
// Create records // Create records
if (isset($this->_fixtures) && isset($this->db) && !in_array(low($method), array('start', 'end'))) { if (isset($this->_fixtures) && isset($this->db) && !in_array(low($method), array('start', 'end')) && $this->__truncated) {
foreach ($this->_fixtures as $fixture) { foreach ($this->_fixtures as $fixture) {
$inserts = $fixture->insert(); $inserts = $fixture->insert();
@ -368,6 +369,9 @@ class CakeTestCase extends UnitTestCase {
foreach ($this->_fixtures as $fixture) { foreach ($this->_fixtures as $fixture) {
$this->db->truncate($fixture->table); $this->db->truncate($fixture->table);
} }
$this->__truncated = true;
} else {
$this->__truncated = false;
} }
if (!in_array(low($method), $this->methods)) { if (!in_array(low($method), $this->methods)) {