diff --git a/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php b/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php index d6c4fc1f0..d5cee102e 100644 --- a/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php +++ b/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php @@ -414,7 +414,7 @@ class CakeTestCaseTest extends CakeTestCase { ) ), App::RESET); $Post = $this->getMockForModel('Post'); - + $this->assertEquals('test', $Post->useDbConfig); $this->assertInstanceOf('Post', $Post); $this->assertNull($Post->save(array())); $this->assertNull($Post->find('all')); diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index e457a033b..491a0f0aa 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -732,12 +732,12 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase { $mock = $this->getMock($name, $methods, array($config)); $availableDs = array_keys(ConnectionManager::enumConnectionObjects()); - if ($mock->useDbConfig === 'default') { - $mock->useDbConfig = null; - $mock->setDataSource('test'); - } + if ($mock->useDbConfig !== 'test' && in_array('test_' . $mock->useDbConfig, $availableDs)) { $mock->setDataSource('test_' . $mock->useDbConfig); + } else { + $mock->useDbConfig = 'test'; + $mock->setDataSource('test'); } ClassRegistry::removeObject($name);