|
|
@@ -194,8 +194,7 @@ class QueryRegressionTest extends TestCase {
|
|
|
$articles->belongsToMany('Tags');
|
|
|
$tags->belongsToMany('Articles');
|
|
|
|
|
|
- $result = $articles->find()->contain(['Tags'])->first();
|
|
|
- $sub = $articles->Tags->find()->select(['id'])->matching('Articles', function ($q) use ($result) {
|
|
|
+ $sub = $articles->Tags->find()->select(['id'])->matching('Articles', function ($q) {
|
|
|
return $q->where(['Articles.id' => 1]);
|
|
|
});
|
|
|
|
|
|
@@ -522,4 +521,18 @@ class QueryRegressionTest extends TestCase {
|
|
|
$this->assertCount(3, $results);
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Tests that calling count on a query having a union works correctly
|
|
|
+ *
|
|
|
+ * @see https://github.com/cakephp/cakephp/issues/5107
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testCountWithUnionQuery() {
|
|
|
+ $table = TableRegistry::get('Articles');
|
|
|
+ $query = $table->find()->where(['id' => 1]);
|
|
|
+ $query2 = $table->find()->where(['id' => 2]);
|
|
|
+ $query->union($query2);
|
|
|
+ $this->assertEquals(2, $query->count());
|
|
|
+ }
|
|
|
+
|
|
|
}
|