Merge pull request #5976 from kulltc/master

Make sure default datasource is not used for mock
This commit is contained in:
Mark Story 2015-02-27 17:41:55 -05:00
commit 54edb1cfa6
2 changed files with 5 additions and 5 deletions

View file

@ -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'));

View file

@ -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);