mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Starting to lazy load database conenctions again, model read tests fixed
This commit is contained in:
parent
a79877d11a
commit
fc060b5e9c
2 changed files with 12 additions and 18 deletions
|
@ -944,6 +944,7 @@ class DboSource extends DataSource {
|
|||
$linkModel = $model->{$assoc};
|
||||
$external = isset($assocData['external']);
|
||||
|
||||
$linkModel->getDataSource();
|
||||
if ($model->useDbConfig == $linkModel->useDbConfig) {
|
||||
if (true === $this->generateAssociationQuery($model, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null)) {
|
||||
$linkedModels[$type . '/' . $assoc] = true;
|
||||
|
|
|
@ -3496,19 +3496,16 @@ class ModelReadTest extends BaseModelTest {
|
|||
* @return void
|
||||
*/
|
||||
public function testFindNeighbors() {
|
||||
$this->loadFixtures('User', 'Article');
|
||||
$this->loadFixtures('User', 'Article', 'Comment', 'Tag', 'ArticlesTag', 'Attachment');
|
||||
$TestModel = new Article();
|
||||
|
||||
$TestModel->id = 1;
|
||||
$result = $TestModel->find('neighbors', array('fields' => array('id')));
|
||||
$expected = array(
|
||||
'prev' => null,
|
||||
'next' => array(
|
||||
'Article' => array('id' => 2),
|
||||
'Comment' => array(),
|
||||
'Tag' => array()
|
||||
));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->assertNull($result['prev']);
|
||||
$this->assertEqual($result['next']['Article'], array('id' => 2));
|
||||
$this->assertEqual(count($result['next']['Comment']), 2);
|
||||
$this->assertEqual(count($result['next']['Tag']), 2);
|
||||
|
||||
$TestModel->id = 2;
|
||||
$TestModel->recursive = 0;
|
||||
|
@ -3530,15 +3527,11 @@ class ModelReadTest extends BaseModelTest {
|
|||
$TestModel->id = 3;
|
||||
$TestModel->recursive = 1;
|
||||
$result = $TestModel->find('neighbors', array('fields' => array('id')));
|
||||
$expected = array(
|
||||
'prev' => array(
|
||||
'Article' => array('id' => 2),
|
||||
'Comment' => array(),
|
||||
'Tag' => array()
|
||||
),
|
||||
'next' => null
|
||||
);
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->assertNull($result['next']);
|
||||
$this->assertEqual($result['prev']['Article'], array('id' => 2));
|
||||
$this->assertEqual(count($result['prev']['Comment']), 2);
|
||||
$this->assertEqual(count($result['prev']['Tag']), 2);
|
||||
|
||||
$TestModel->id = 1;
|
||||
$result = $TestModel->find('neighbors', array('recursive' => -1));
|
||||
|
|
Loading…
Add table
Reference in a new issue