Skip to content
Permalink
Browse files

Adding missing test to prove select strategy for HasMany still works

  • Loading branch information...
lorenzo committed May 24, 2013
1 parent 328fcb1 commit cfd34ff059d6ba7e53d57800447fe0ee8435c2c1
Showing with 16 additions and 3 deletions.
  1. +16 −3 lib/Cake/Test/TestCase/ORM/QueryTest.php
@@ -323,17 +323,29 @@ public function testContainResultFetchingOneLevel() {
}
/**
* Tests that HasMany associations are correctly eager loaded
* Data provider for the two types of strategies HasMany implements
*
* @return void
*/
public function strategiesProvider() {
return [['subquery', 'select']];
}
/**
* Tests that HasMany associations are correctly eager loaded.
* Also that the query object passes the correct parent model keys to the
* association objects in order to perform eager loading with select strategy
*
* @dataProvider strategiesProvider
* @return void
**/
public function testHasManyEagerLoading() {
public function testHasManyEagerLoading($strategy) {
$this->_insertRecords();
$query = new Query($this->connection);
$table = Table::build('author', ['connection' => $this->connection]);
Table::build('article', ['connection' => $this->connection]);
$table->hasMany('article', ['property' => 'articles']);
$table->hasMany('article', ['property' => 'articles', 'strategy' => $strategy]);
$results = $query->repository($table)->select()->contain('article')->toArray();
$expected = [
@@ -370,6 +382,7 @@ public function testHasManyEagerLoading() {
->toArray();
unset($expected[0]['articles']);
$this->assertEquals($expected, $results);
$this->assertEquals($table->association('article')->strategy(), $strategy);
}
/**

0 comments on commit cfd34ff

Please sign in to comment.
You can’t perform that action at this time.