Permalink
Browse files

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

associations
  • Loading branch information...
1 parent 8501c6e commit a115e908cec0a53892c63c1022270591f5acbee0 @lorenzo lorenzo committed Jan 26, 2014
Showing with 16 additions and 0 deletions.
  1. +16 −0 tests/TestCase/Model/Behavior/TranslateBehaviorTest.php
@@ -308,4 +308,20 @@ public function testFindSingleLocaleHasMany() {
$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));
+ }
+
}

0 comments on commit a115e90

Please sign in to comment.