浏览代码

Added test to prove that using translate behavior and union queries now works

Jose Lorenzo Rodriguez 11 年之前
父节点
当前提交
0277c3fec5
共有 1 个文件被更改,包括 19 次插入0 次删除
  1. 19 0
      tests/TestCase/Model/Behavior/TranslateBehaviorTest.php

+ 19 - 0
tests/TestCase/Model/Behavior/TranslateBehaviorTest.php

@@ -794,4 +794,23 @@ class TranslateBehaviorTest extends TestCase {
 		$this->assertEquals('Un artículo', $article->translation('spa')->title);
 		$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);
+	}
+
 }
 }