diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index c57124a5a..3544804bd 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -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; diff --git a/cake/tests/cases/libs/model/model_read.test.php b/cake/tests/cases/libs/model/model_read.test.php index 8788b04af..1a87f0ac4 100755 --- a/cake/tests/cases/libs/model/model_read.test.php +++ b/cake/tests/cases/libs/model/model_read.test.php @@ -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));