Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add test for bindModel + containable.

Closes #1821
  • Loading branch information...
commit a64099168cb05a1e3c5f4bf87ae3b8b54c2000b2 1 parent 26d80de
@markstory markstory authored
Showing with 35 additions and 0 deletions.
  1. +35 −0 cake/tests/cases/libs/model/behaviors/containable.test.php
View
35 cake/tests/cases/libs/model/behaviors/containable.test.php
@@ -3609,6 +3609,41 @@ function testResetMultipleHabtmAssociations() {
}
/**
+ * 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.
*
* @return void
Please sign in to comment.
Something went wrong with that request. Please try again.