/** Verifies that we are not connected to the production database. * * @param bool $force * * @return void Triggers an error if our database connection is unsafe for * testing. */ private function _assertTestDatabaseConnection($force = false) { if ((!self::$_dbNameCheck or $force) and $db = $this->getDatabaseConnection()) { $this->_assertTestEnvironment(); $config = sfConfigHandler::replaceConstants(sfYaml::load(sfConfig::get('sf_root_dir') . '/config/databases.yml')); /* Check to see if a test database has been specified. */ if (empty($config['test']['doctrine']['param']['dsn'])) { self::_halt('Please specify a "test" database in databases.yml.'); } $test = $config['test']['doctrine']['param']['dsn']; $prod = isset($config['prod']['doctrine']['param']['dsn']) ? $config['prod']['doctrine']['param']['dsn'] : $config['all']['doctrine']['param']['dsn']; /* Check to see if a *separate* test database has been specified. */ if ($prod == $test) { self::_halt('Please specify a *separate* "test" database in databases.yml.'); } /* Check to see that the active connection is using the correct DSN. */ if ($db->getOption('dsn') != $test) { self::_halt('Doctrine connection is not using test DSN!'); } self::$_dbNameCheck = true; } }