Starting to lazy load database conenctions again, model read tests fixed

This commit is contained in:
José Lorenzo Rodríguez 2011-02-23 00:43:56 -04:30
parent a79877d11a
commit fc060b5e9c
2 changed files with 12 additions and 18 deletions

View file

@ -944,6 +944,7 @@ class DboSource extends DataSource {
$linkModel = $model->{$assoc}; $linkModel = $model->{$assoc};
$external = isset($assocData['external']); $external = isset($assocData['external']);
$linkModel->getDataSource();
if ($model->useDbConfig == $linkModel->useDbConfig) { if ($model->useDbConfig == $linkModel->useDbConfig) {
if (true === $this->generateAssociationQuery($model, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null)) { if (true === $this->generateAssociationQuery($model, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null)) {
$linkedModels[$type . '/' . $assoc] = true; $linkedModels[$type . '/' . $assoc] = true;

View file

@ -3496,19 +3496,16 @@ class ModelReadTest extends BaseModelTest {
* @return void * @return void
*/ */
public function testFindNeighbors() { public function testFindNeighbors() {
$this->loadFixtures('User', 'Article'); $this->loadFixtures('User', 'Article', 'Comment', 'Tag', 'ArticlesTag', 'Attachment');
$TestModel = new Article(); $TestModel = new Article();
$TestModel->id = 1; $TestModel->id = 1;
$result = $TestModel->find('neighbors', array('fields' => array('id'))); $result = $TestModel->find('neighbors', array('fields' => array('id')));
$expected = array(
'prev' => null, $this->assertNull($result['prev']);
'next' => array( $this->assertEqual($result['next']['Article'], array('id' => 2));
'Article' => array('id' => 2), $this->assertEqual(count($result['next']['Comment']), 2);
'Comment' => array(), $this->assertEqual(count($result['next']['Tag']), 2);
'Tag' => array()
));
$this->assertEqual($result, $expected);
$TestModel->id = 2; $TestModel->id = 2;
$TestModel->recursive = 0; $TestModel->recursive = 0;
@ -3530,15 +3527,11 @@ class ModelReadTest extends BaseModelTest {
$TestModel->id = 3; $TestModel->id = 3;
$TestModel->recursive = 1; $TestModel->recursive = 1;
$result = $TestModel->find('neighbors', array('fields' => array('id'))); $result = $TestModel->find('neighbors', array('fields' => array('id')));
$expected = array(
'prev' => array( $this->assertNull($result['next']);
'Article' => array('id' => 2), $this->assertEqual($result['prev']['Article'], array('id' => 2));
'Comment' => array(), $this->assertEqual(count($result['prev']['Comment']), 2);
'Tag' => array() $this->assertEqual(count($result['prev']['Tag']), 2);
),
'next' => null
);
$this->assertEqual($result, $expected);
$TestModel->id = 1; $TestModel->id = 1;
$result = $TestModel->find('neighbors', array('recursive' => -1)); $result = $TestModel->find('neighbors', array('recursive' => -1));