Skip to content

Commit

Permalink
Added test to prove that using translate behavior and union queries n…
Browse files Browse the repository at this point in the history
…ow works
  • Loading branch information
lorenzo committed Nov 9, 2014
1 parent 33595f3 commit 0277c3f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/TestCase/Model/Behavior/TranslateBehaviorTest.php
Expand Up @@ -794,4 +794,23 @@ public function testSavingWithNonDefaultLocale() {
$this->assertEquals('Un artículo', $article->translation('spa')->title);
}

/**
* Tests that translation queries are added to union queries as well.
*
* @return void
*/
public function testTranslationWithUnionQuery() {
$table = TableRegistry::get('Comments');
$table->addBehavior('Translate', ['fields' => ['comment']]);
$table->locale('spa');
$query = $table->find()->where(['Comments.id' => 6]);
$query2 = $table->find()->where(['Comments.id' => 5]);
$query->union($query2);
$results = $query->toArray();
$this->assertCount(2, $results);

$this->assertEquals('First Comment for Second Article', $results[0]->comment);
$this->assertEquals('Second Comment for Second Article', $results[1]->comment);
}

}

0 comments on commit 0277c3f

Please sign in to comment.