mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Make sure default datasource is not used for mock
When a non-default datasource is used for a model and no test_ version of that datasource is available, the getMockForModel method used the models standard datasource, rahter than 'test'.
This commit is contained in:
parent
bc4bca9737
commit
a7c2f26599
2 changed files with 5 additions and 5 deletions
|
@ -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'));
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue