Browse Source

Add tests for empty expression objects in association conditions.

Empty expression objects currently cause invalid SQL when added to
a query. I feel they should be no-ops instead.

Refs #6568
Mark Story 11 years ago
parent
commit
13bdda3fe1
1 changed files with 18 additions and 0 deletions
  1. 18 0
      tests/TestCase/ORM/QueryTest.php

+ 18 - 0
tests/TestCase/ORM/QueryTest.php

@@ -1862,6 +1862,24 @@ class QueryTest extends TestCase
     }
 
     /**
+     * Test containing associations that have empty conditions.
+     *
+     * @return void
+     */
+    public function testContainAssociationWithEmptyConditions()
+    {
+        $articles = TableRegistry::get('Articles');
+        $articles->belongsTo('Authors', [
+            'conditions' => function ($exp, $query) {
+                return $exp;
+            }
+        ]);
+        $query = $articles->find('all')->contain(['Authors']);
+        $result = $query->toArray();
+        $this->assertCount(4, $result);
+    }
+
+    /**
      * Tests the formatResults method
      *
      * @return void