From 13bdda3fe1983cc1bffa775f64d3cb3a36dfe2c2 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 17 May 2015 22:14:56 -0400 Subject: [PATCH] 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 --- tests/TestCase/ORM/QueryTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/TestCase/ORM/QueryTest.php b/tests/TestCase/ORM/QueryTest.php index 57636169916..50f26517a50 100644 --- a/tests/TestCase/ORM/QueryTest.php +++ b/tests/TestCase/ORM/QueryTest.php @@ -1861,6 +1861,24 @@ public function testContainWithQueryBuilderJoinableAssociation() $this->assertEquals(1, $result[0]->author->id); } + /** + * 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 *