Skip to content

Commit

Permalink
Added failing tests for implementing find('translations') on
Browse files Browse the repository at this point in the history
associations
  • Loading branch information
lorenzo committed Jan 26, 2014
1 parent 8501c6e commit a115e90
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/TestCase/Model/Behavior/TranslateBehaviorTest.php
Expand Up @@ -308,4 +308,20 @@ public function testFindSingleLocaleHasMany() {
$this->assertEquals($expected, $list->combine('id', 'comment')->toArray()); $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.