Skip to content

Instantly share code, notes, and snippets.

@k1LoW
Created July 15, 2009 08:51
Show Gist options
  • Save k1LoW/147586 to your computer and use it in GitHub Desktop.
Save k1LoW/147586 to your computer and use it in GitHub Desktop.
<?php
/**
* Runs as first test to create tables.
*
* @return void
* @access public
*/
function start() {
if (isset($this->_fixtures) && isset($this->db)) {
Configure::write('Cache.disable', true);
$cacheSources = $this->db->cacheSources;
$this->db->cacheSources = false;
$sources = $this->db->listSources();
$this->db->cacheSources = $cacheSources;
if (!$this->dropTables) {
return;
}
foreach ($this->_fixtures as $fixture) {
if ($this->db->_baseConfig['connect'] == 'pg_connect' || $this->db->_baseConfig['connect'] == 'pg_pconnect') {
$table = $this->db->config['prefix'] . $fixture->table;
}
if (in_array($table, $sources)) {
$fixture->drop($this->db);
$fixture->create($this->db);
} elseif (!in_array($table, $sources)) {
$fixture->create($this->db);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment