Adding a check to prevent if $test is not defined in DATABASE_CONFIG

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4944 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2007-04-30 10:27:58 +00:00
parent c61e30e6f2
commit 860c8d3ddc

View file

@ -403,13 +403,24 @@ class CakeTestCase extends UnitTestCase {
* *
*/ */
function _initDb() { function _initDb() {
// Try for test DB $testDbAvailable = false;
restore_error_handler();
@$db =& ConnectionManager::getDataSource('test'); if (class_exists('DATABASE_CONFIG')) {
set_error_handler('simpleTestErrorHandler'); $dbConfig =& new DATABASE_CONFIG();
$testDbAvailable = isset($dbConfig->test);
}
if ($testDbAvailable) {
// Try for test DB
restore_error_handler();
@$db =& ConnectionManager::getDataSource('test');
set_error_handler('simpleTestErrorHandler');
$testDbAvailable = $db->isConnected();
}
// Try for default DB // Try for default DB
if (!$db->isConnected()) { if (!$testDbAvailable) {
$db =& ConnectionManager::getDataSource('default'); $db =& ConnectionManager::getDataSource('default');
} }