mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch '1.3-misc' of code.cakephp.org:cakephp into 1.3-misc
This commit is contained in:
commit
4ec75c6052
3 changed files with 31 additions and 1 deletions
|
@ -2020,7 +2020,6 @@ class Model extends Overloadable {
|
|||
list($type, $query) = array($conditions, $fields);
|
||||
}
|
||||
|
||||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||
$this->findQueryType = $type;
|
||||
$this->id = $this->getID();
|
||||
|
||||
|
@ -2067,6 +2066,9 @@ class Model extends Overloadable {
|
|||
}
|
||||
}
|
||||
|
||||
if (!$db =& ConnectionManager::getDataSource($this->useDbConfig)) {
|
||||
return false;
|
||||
}
|
||||
$results = $db->read($this, $query);
|
||||
$this->resetAssociations();
|
||||
$this->findQueryType = null;
|
||||
|
|
|
@ -4877,6 +4877,22 @@ class ModelReadTest extends BaseModelTest {
|
|||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the database configuration assigned to the model can be changed using
|
||||
* (before|after)Find callbacks
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testCallbackSourceChange() {
|
||||
$this->loadFixtures('Post');
|
||||
$TestModel = new Post();
|
||||
$this->assertEqual(3, count($TestModel->find('all')));
|
||||
|
||||
$this->expectError(new PatternExpectation('/Non-existent data source foo/i'));
|
||||
$this->expectError(new PatternExpectation('/Only variable references/i'));
|
||||
$this->assertFalse($TestModel->find('all', array('connection' => 'foo')));
|
||||
}
|
||||
|
||||
/**
|
||||
* testMultipleBelongsToWithSameClass method
|
||||
*
|
||||
|
|
|
@ -857,6 +857,18 @@ class Post extends CakeTestModel {
|
|||
* @access public
|
||||
*/
|
||||
var $belongsTo = array('Author');
|
||||
|
||||
function beforeFind($queryData) {
|
||||
if (isset($queryData['connection'])) {
|
||||
$this->useDbConfig = $queryData['connection'];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function afterFind($results) {
|
||||
$this->useDbConfig = 'test_suite';
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue