mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Removed collision with testCase fixtures, causing fixtures to be missing when running testAction() more than once per test case. Closes #5267
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7469 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
5874916ccb
commit
fb5a0a6f12
1 changed files with 9 additions and 10 deletions
|
@ -170,7 +170,8 @@ class CakeTestCase extends UnitTestCase {
|
|||
if ((is_array($params['fixturize']) && in_array($name, $params['fixturize'])) || $params['fixturize'] === true) {
|
||||
if (class_exists($name) || App::import('Model', $name)) {
|
||||
$object =& ClassRegistry::init($name);
|
||||
|
||||
//switch back to specified datasource.
|
||||
$object->setDataSource($params['connection']);
|
||||
$db =& ConnectionManager::getDataSource($object->useDbConfig);
|
||||
$db->cacheSources = false;
|
||||
|
||||
|
@ -182,11 +183,10 @@ class CakeTestCase extends UnitTestCase {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
ClassRegistry::config(array('ds' => 'test_suite'));
|
||||
|
||||
if (!empty($models) && isset($this->db)) {
|
||||
$this->_fixtures = array();
|
||||
$this->_actionFixtures = array();
|
||||
|
||||
foreach ($models as $model) {
|
||||
$fixture =& new CakeTestFixture($this->db);
|
||||
|
@ -194,12 +194,11 @@ class CakeTestCase extends UnitTestCase {
|
|||
$fixture->name = $model['model'] . 'Test';
|
||||
$fixture->table = $model['table'];
|
||||
$fixture->import = array('model' => $model['model'], 'records' => true);
|
||||
|
||||
$fixture->init();
|
||||
|
||||
$fixture->create($this->db);
|
||||
$fixture->insert($this->db);
|
||||
$this->_fixtures[] =& $fixture;
|
||||
$this->_actionFixtures[] =& $fixture;
|
||||
}
|
||||
|
||||
foreach ($models as $model) {
|
||||
|
@ -219,8 +218,8 @@ class CakeTestCase extends UnitTestCase {
|
|||
* * @param array $params Additional parameters as sent by testAction().
|
||||
*/
|
||||
function endController(&$controller, $params = array()) {
|
||||
if (isset($this->db) && isset($this->_fixtures) && !empty($this->_fixtures)) {
|
||||
foreach ($this->_fixtures as $fixture) {
|
||||
if (isset($this->db) && isset($this->_actionFixtures) && !empty($this->_actionFixtures)) {
|
||||
foreach ($this->_actionFixtures as $fixture) {
|
||||
$fixture->drop($this->db);
|
||||
}
|
||||
}
|
||||
|
@ -314,8 +313,8 @@ class CakeTestCase extends UnitTestCase {
|
|||
$result = @$dispatcher->dispatch($url, $params);
|
||||
}
|
||||
|
||||
if (isset($this->_fixtures)) {
|
||||
unset($this->_fixtures);
|
||||
if (isset($this->_actionFixtures)) {
|
||||
unset($this->_actionFixtures);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
|
Loading…
Reference in a new issue