Skip to content
Permalink
Browse files

Fixing fatal error caused by associated models using a datasource tha…

…t is not a subclass of dbo_source. Test added. Fixes #873

Conflicts:

	cake/tests/cases/libs/model/datasources/dbo_source.test.php
  • Loading branch information...
markstory committed Jul 11, 2010
1 parent 2b8bc02 commit 5c1b381e8abc56458d365e5f29b8ab7d4dc8f7fe
@@ -675,7 +675,7 @@ function read(&$model, $queryData = array(), $recursive = null) {
$db =& $this;
}
if (isset($db)) {
if (isset($db) && method_exists($db, 'queryAssociation')) {
$stack = array($assoc);
$db->queryAssociation($model, $linkModel, $type, $assoc, $assocData, $array, true, $resultSet, $model->recursive - 1, $stack);
unset($db);
@@ -2492,4 +2492,4 @@ function introspectType($value) {
return 'string';
}
}
?>
?>
@@ -1225,6 +1225,7 @@ function getLastQuery() {
function endTest() {
unset($this->Model);
Configure::write('debug', $this->debug);
ClassRegistry::flush();
unset($this->debug);
}
/**
@@ -3883,5 +3884,35 @@ function testShowQuery() {
$this->assertNoPattern('/Num:/s', $contents);
$this->assertNoPattern('/Took:/s', $contents);
}
/**
* test the permutations of fullTableName()
*
* @return void
*/
function testFullTablePermutations() {
$Article =& ClassRegistry::init('Article');
$result = $this->testDb->fullTableName($Article, false);
$this->assertEqual($result, 'articles');
$Article->tablePrefix = 'tbl_';
$result = $this->testDb->fullTableName($Article, false);
$this->assertEqual($result, 'tbl_articles');
}
/**
* test that read() only calls queryAssociation on db objects when the method is defined.
*
* @return void
*/
function testReadOnlyCallingQueryAssociationWhenDefined() {
ConnectionManager::create('test_no_queryAssociation', array(
'datasource' => 'data'
));
$Article =& ClassRegistry::init('Article');
$Article->Comment->useDbConfig = 'test_no_queryAssociation';
$result = $Article->find('all');
$this->assertTrue(is_array($result));
}
}
?>

0 comments on commit 5c1b381

Please sign in to comment.
You can’t perform that action at this time.