Skip to content
Permalink
Browse files

Add test for bindModel + containable.

Closes #1821
  • Loading branch information...
markstory committed Sep 18, 2011
1 parent 26d80de commit a64099168cb05a1e3c5f4bf87ae3b8b54c2000b2
Showing with 35 additions and 0 deletions.
  1. +35 −0 cake/tests/cases/libs/model/behaviors/containable.test.php
@@ -3608,6 +3608,41 @@ function testResetMultipleHabtmAssociations() {
$this->assertEqual($expected, $this->Article->hasAndBelongsToMany);
}
/**
* test that bindModel and unbindModel work with find() calls in between.
*/
function testBindMultipleTimesWithFind() {
$binding = array(
'hasOne' => array(
'ArticlesTag' => array(
'foreignKey' => false,
'type' => 'INNER',
'conditions' => array(
'ArticlesTag.article_id = Article.id'
)
),
'Tag' => array(
'type' => 'INNER',
'foreignKey' => false,
'conditions' => array(
'ArticlesTag.tag_id = Tag.id'
)
)
)
);
$this->Article->unbindModel(array('hasAndBelongsToMany' => array('Tag')));
$this->Article->bindModel($binding);
$result = $this->Article->find('all', array('limit' => 1, 'contain' => array('ArticlesTag', 'Tag')));
$this->Article->unbindModel(array('hasAndBelongsToMany' => array('Tag')));
$this->Article->bindModel($binding);
$result = $this->Article->find('all', array('limit' => 1, 'contain' => array('ArticlesTag', 'Tag')));
$associated = $this->Article->getAssociated();
$this->assertEqual('hasAndBelongsToMany', $associated['Tag']);
$this->assertFalse(isset($associated['ArticleTag']));
}
/**
* test that autoFields doesn't splice in fields from other databases.
*

0 comments on commit a640991

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