mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06: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() {
|
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');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue