mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 00:48:25 +00:00
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:
parent
7e9b05e429
commit
e1a0f554e1
1 changed files with 5 additions and 1 deletions
|
@ -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)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue