Permalink
Browse files

fix contain for find method

  • Loading branch information...
dereuromark committed Aug 13, 2012
1 parent 11227f5 commit e1fbfcef005a1b876fe527dbf9c03703bfece269
@@ -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']
@@ -261,6 +261,30 @@ public function testContain() {
$this->assertFalse(Set::matches('/Comment/User', $r));
}
/**
* 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
*

0 comments on commit e1fbfce

Please sign in to comment.