Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix contain for find method

  • Loading branch information...
commit e1fbfcef005a1b876fe527dbf9c03703bfece269 1 parent 11227f5
@dereuromark dereuromark authored
View
2  lib/Cake/Model/Behavior/ContainableBehavior.php
@@ -171,7 +171,7 @@ public function beforeFind(Model $Model, $query) {
}
if ($this->settings[$Model->alias]['recursive']) {
- $query['recursive'] = (isset($query['recursive'])) ? $query['recursive'] : $containments['depth'];
+ $query['recursive'] = (isset($query['recursive'])) ? max($query['recursive'], $containments['depth']) : $containments['depth'];
}
$autoFields = ($this->settings[$Model->alias]['autoFields']
View
24 lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php
@@ -262,6 +262,30 @@ public function testContain() {
}
/**
+ * testContainFindList method
+ *
+ * @return void
+ */
+ public function testContainFindList() {
+ $this->Article->contain('Comment.User');
+ $result = $this->Article->find('list');
+ $expected = array(
+ 1 => 'First Article',
+ 2 => 'Second Article',
+ 3 => 'Third Article'
+ );
+ $this->assertEquals($expected, $result);
+
+ $result = $this->Article->find('list', array('fields'=>array('Article.id', 'User.id'), 'contain'=>array('User')));
+ $expected = array(
+ 1 => '1',
+ 2 => '3',
+ 3 => '1'
+ );
+ $this->assertEquals($expected, $result);
+ }
+
+/**
* testFindEmbeddedNoBindings method
*
* @return void
Please sign in to comment.
Something went wrong with that request. Please try again.