Browse Source

Added failing tests for implementing find('translations') on
associations

Jose Lorenzo Rodriguez 12 years ago
parent
commit
a115e908ce
1 changed files with 16 additions and 0 deletions
  1. 16 0
      tests/TestCase/Model/Behavior/TranslateBehaviorTest.php

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

@@ -308,4 +308,20 @@ class TranslateBehaviorTest extends TestCase {
 		$this->assertEquals($expected, $list->combine('id', 'comment')->toArray());
 	}
 
+	public function testTranslationsHasMany() {
+		$table = TableRegistry::get('Articles');
+		$table->addBehavior('Translate', ['fields' => ['title', 'body']]);
+		$table->hasMany('Comments');
+		$comments = $table->hasMany('Comments')->target();
+		$comments->addBehavior('Translate', ['fields' => ['comment']]);
+
+		$results = $table->find('translations')->contain(['Comments' => function($q) {
+			return $q->find('translations')->select(['id', 'comment', 'article_id']);
+		}]);
+
+
+		$article = $results->first();
+		debug(json_encode($article, JSON_PRETTY_PRINT));
+	}
+
 }