mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
fix contain for find method
This commit is contained in:
parent
11227f5490
commit
e1fbfcef00
2 changed files with 25 additions and 1 deletions
|
@ -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']
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue