Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Asserting that tuple comparison is used for eager laoding HasMany

  • Loading branch information...
commit f664429fa0d3180329ddda4ac012d9ba4504835b 1 parent f0ba802
@lorenzo lorenzo authored
Showing with 9 additions and 1 deletion.
  1. +9 −1 Test/TestCase/ORM/Association/HasManyTest.php
View
10 Test/TestCase/ORM/Association/HasManyTest.php
@@ -18,6 +18,7 @@
use Cake\Database\Expression\IdentifierExpression;
use Cake\Database\Expression\QueryExpression;
+use Cake\Database\Expression\TupleComparison;
use Cake\ORM\Association\HasMany;
use Cake\ORM\Entity;
use Cake\ORM\Query;
@@ -430,7 +431,7 @@ public function testEagerLoaderMultipleKeys() {
$this->author->primaryKey(['id', 'site_id']);
$association = new HasMany('Articles', $config);
$keys = [[1, 10], [2, 20], [3, 30], [4, 40]];
- $query = $this->getMock('Cake\ORM\Query', ['all'], [null, null]);
+ $query = $this->getMock('Cake\ORM\Query', ['all', 'andWhere'], [null, null]);
$this->article->expects($this->once())->method('find')->with('all')
->will($this->returnValue($query));
$results = [
@@ -440,6 +441,13 @@ public function testEagerLoaderMultipleKeys() {
$query->expects($this->once())->method('all')
->will($this->returnValue($results));
+ $tuple = new TupleComparison(
+ ['Articles.author_id', 'Articles.site_id'], $keys, [], 'IN'
+ );
+ $query->expects($this->once())->method('andWhere')
+ ->with($tuple)
+ ->will($this->returnSelf());
+
$callable = $association->eagerLoader(compact('keys', 'query'));
$row = ['Authors__id' => 2, 'Authors__site_id' => 10, 'username' => 'author 1'];
$result = $callable($row);
Please sign in to comment.
Something went wrong with that request. Please try again.