Browse Source

Add test for

Mark Story 10 years ago
parent
commit
6152546e1a
1 changed files with 20 additions and 0 deletions
  1. 20 0
      tests/TestCase/ORM/QueryRegressionTest.php

+ 20 - 0
tests/TestCase/ORM/QueryRegressionTest.php

@@ -904,4 +904,24 @@ class QueryRegressionTest extends TestCase
             'Output values for functions are not cast yet.'
         );
     }
+
+    public function testBooleanConditionsInContain()
+    {
+        $table = TableRegistry::get('Articles');
+        $table->belongsToMany('Tags', [
+            'foreignKey' => 'article_id',
+            'associationForeignKey' => 'tag_id',
+            'through' => 'SpecialTags'
+        ]);
+        $query = $table->find()
+            ->contain(['Tags' => function ($q) {
+                return $q->where(['SpecialTags.highlighted' => false]);
+            }])
+            ->order(['Articles.id' => 'ASC']);
+
+        $result = $query->first();
+        $this->assertEquals(1, $result->id);
+        $this->assertNotEmpty($result->tags);
+        $this->assertNotEmpty($result->tags[0]->_joinData);
+    }
 }