Skip to content

Commit

Permalink
Improved performance of CakeFixtureManager.
Browse files Browse the repository at this point in the history
  • Loading branch information
bancer committed Aug 5, 2017
1 parent 895f6ca commit d910594
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/Cake/TestSuite/Fixture/CakeFixtureManager.php
Expand Up @@ -175,7 +175,7 @@ protected function _loadFixtures($fixtures) {
}

/**
* Runs the drop and create commands on the fixtures if necessary.
* Runs the drop, create and truncate commands on the fixtures if necessary.
*
* @param CakeTestFixture $fixture the fixture object to create
* @param DataSource $db the datasource instance to use
Expand All @@ -191,6 +191,7 @@ protected function _setupTable($fixture, $db = null, $drop = true) {
}
}
if (!empty($fixture->created) && in_array($db->configKeyName, $fixture->created)) {
$fixture->truncate($db);
return;
}

Expand All @@ -205,6 +206,7 @@ protected function _setupTable($fixture, $db = null, $drop = true) {
$fixture->create($db);
} else {
$fixture->created[] = $db->configKeyName;
$fixture->truncate($db);
}
}

Expand All @@ -229,7 +231,6 @@ public function load(CakeTestCase $test) {
$db = ConnectionManager::getDataSource($fixture->useDbConfig);
$db->begin();
$this->_setupTable($fixture, $db, $test->dropTables);
$fixture->truncate($db);
$fixture->insert($db);
$db->commit();
}
Expand Down Expand Up @@ -274,7 +275,6 @@ public function loadSingle($name, $db = null, $dropTables = true) {
$db = ConnectionManager::getDataSource($fixture->useDbConfig);
}
$this->_setupTable($fixture, $db, $dropTables);
$fixture->truncate($db);
$fixture->insert($db);
} else {
throw new UnexpectedValueException(__d('cake_dev', 'Referenced fixture class %s not found', $name));
Expand Down

0 comments on commit d910594

Please sign in to comment.