Skip to content
Permalink
Browse files

Add test for #7591

  • Loading branch information...
chinpei215 committed Nov 21, 2015
1 parent a154b01 commit 4e1e4f84fe426b7a31273068ff69aba9f1e6a9e1
Showing with 21 additions and 0 deletions.
  1. +21 −0 tests/TestCase/ORM/QueryRegressionTest.php
@@ -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.

0 comments on commit 4e1e4f8

Please sign in to comment.
You can’t perform that action at this time.