File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -2280,4 +2280,29 @@ public function testContainWithStrategyOverride() {
2280
2280
$ this ->assertNull ($ articles [2 ]->author );
2281
2281
}
2282
2282
2283
+ /**
2284
+ * Tests that it is possible to call matching and contain on the same
2285
+ * association.
2286
+ *
2287
+ * @return void
2288
+ */
2289
+ public function testMatchingWithContain () {
2290
+ $ query = new Query ($ this ->connection , $ this ->table );
2291
+ $ table = TableRegistry::get ('authors ' );
2292
+ $ table ->hasMany ('articles ' );
2293
+ TableRegistry::get ('articles ' )->belongsToMany ('tags ' );
2294
+
2295
+ $ result = $ query ->repository ($ table )
2296
+ ->select ()
2297
+ ->matching ('articles.tags ' , function ($ q ) {
2298
+ return $ q ->where (['tags.id ' => 2 ]);
2299
+ })
2300
+ ->contain ('articles ' )
2301
+ ->first ();
2302
+
2303
+ $ this ->assertEquals (1 , $ result ->id );
2304
+ $ this ->assertCount (2 , $ result ->articles );
2305
+ $ this ->assertEquals (2 , $ result ->_matchingData ['tags ' ]->id );
2306
+ }
2307
+
2283
2308
}
You can’t perform that action at this time.
0 commit comments