Skip to content

Commit

Permalink
Merge branch 'master-issue7591' of https://github.com/chinpei215/cakephp
Browse files Browse the repository at this point in the history
 into issue7591
  • Loading branch information
lorenzo committed Dec 6, 2015
2 parents c2bd05c + 4e1e4f8 commit 1f4a428
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/TestCase/ORM/QueryRegressionTest.php
Expand Up @@ -943,6 +943,27 @@ public function testFindLastOnEmptyTable()
$this->assertNull($table->find()->last());
}

/**
* Tests calling contain in a nested closure
*
* @see https://github.com/cakephp/cakephp/issues/7591
* @return void
*/
public function testContainInNestedClosure()
{
$table = TableRegistry::get('Comments');
$table->belongsTo('Articles');
$table->Articles->belongsTo('Authors');
$table->Articles->Authors->belongsToMany('Tags');

$query = $table->find()->where(['Comments.id' => 5])->contain(['Articles' => function ($q) {
return $q->contain(['Authors' => function ($q) {
return $q->contain('Tags');
}]);
}]);
$this->assertCount(2, $query->first()->article->author->tags);
}

/**
* Test that the typemaps used in function expressions
* create the correct results.
Expand Down

0 comments on commit 1f4a428

Please sign in to comment.