Skip to content
Permalink
Browse files

Adding a test case to prove #4454

  • Loading branch information...
lorenzo committed Sep 1, 2014
1 parent 001ec16 commit cb6c095723246d1164527958d7c93e7cbfed2bef
Showing with 31 additions and 0 deletions.
  1. +31 −0 tests/TestCase/ORM/QueryRegressionTest.php
@@ -374,4 +374,35 @@ public function testPluginAssociationQueryGeneration() {
);
}
/**
* Tests that loading associations having the same alias in the
* joinable associations chain is not sensitive to the order in which
* the associations are selected.
*
* @see https://github.com/cakephp/cakephp/issues/4454
* @return void
*/
public function testAssociationChainOrder() {
$articles = TableRegistry::get('Articles');
$articles->belongsTo('Authors');
$articles->hasOne('ArticlesTags');
$articlesTags = TableRegistry::get('ArticlesTags');
$articlesTags->belongsTo('Authors', [
'foreignKey' => 'tag_id'
]);
$resultA = $articles->find()
->contain(['ArticlesTags.Authors', 'Authors'])
->first();
$resultB = $articles->find()
->contain(['Authors', 'ArticlesTags.Authors'])
->first();
$this->assertEquals($resultA, $resultB);
$this->assertNotEmpty($resultA->user);
$this->assertNotEmpty($resultA->articles_tag->user);
}
}

0 comments on commit cb6c095

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