/** * Runs the drop and create commands on the fixtures if necessary. * * @param CakeTestFixture $fixture the fixture object to create * @param DataSource $db the datasource instance to use * @param boolean $drop whether drop the fixture if it is already created or not * @return void */ protected function _setupTable($fixture, $db = null, $drop = true) { if (!$db) { if (!empty($fixture->useDbConfig)) { $db = ClassRegistry::getDataSource($fixture->useDbConfig); } else { $db = $this->_db; } } if (!empty($fixture->created) && in_array($db->configKeyName, $fixture->created)) { return; } $sources = $db->listSources(); $table = $db->config['prefix'] . $fixture->table; if ($drop && in_array($table, $sources)) { $fixture->drop($db); $fixture->create($db); } elseif (!in_array($table, $sources)) { $fixture->create($db); } }