Skip to content

Commit

Permalink
Add tests for empty expression objects in association conditions.
Browse files Browse the repository at this point in the history
Empty expression objects currently cause invalid SQL when added to
a query. I feel they should be no-ops instead.

Refs #6568
  • Loading branch information
markstory committed May 27, 2015
1 parent 3915efe commit 13bdda3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/TestCase/ORM/QueryTest.php
Expand Up @@ -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
*
Expand Down

0 comments on commit 13bdda3

Please sign in to comment.