mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
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:
parent
c61e30e6f2
commit
860c8d3ddc
1 changed files with 16 additions and 5 deletions
|
@ -403,13 +403,24 @@ class CakeTestCase extends UnitTestCase {
|
|||
*
|
||||
*/
|
||||
function _initDb() {
|
||||
// Try for test DB
|
||||
restore_error_handler();
|
||||
@$db =& ConnectionManager::getDataSource('test');
|
||||
set_error_handler('simpleTestErrorHandler');
|
||||
$testDbAvailable = false;
|
||||
|
||||
if (class_exists('DATABASE_CONFIG')) {
|
||||
$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
|
||||
if (!$db->isConnected()) {
|
||||
if (!$testDbAvailable) {
|
||||
$db =& ConnectionManager::getDataSource('default');
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue