fix contain for find method

This commit is contained in:
euromark 2012-08-13 08:10:51 +02:00
parent 11227f5490
commit e1fbfcef00
2 changed files with 25 additions and 1 deletions

View file

@ -171,7 +171,7 @@ class ContainableBehavior extends ModelBehavior {
}
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 file

@ -261,6 +261,30 @@ class ContainableBehaviorTest extends CakeTestCase {
$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
*