|
|
@@ -34,7 +34,8 @@ class TranslateBehaviorTest extends TestCase {
|
|
|
public $fixtures = [
|
|
|
'core.translate',
|
|
|
'core.article',
|
|
|
- 'core.comment'
|
|
|
+ 'core.comment',
|
|
|
+ 'core.author'
|
|
|
];
|
|
|
|
|
|
public function tearDown() {
|
|
|
@@ -393,4 +394,20 @@ class TranslateBehaviorTest extends TestCase {
|
|
|
$this->assertEquals('Obsah #1', $results->first()->body);
|
|
|
}
|
|
|
|
|
|
+ public function testFindSingleLocaleBelongsto() {
|
|
|
+ $table = TableRegistry::get('Articles');
|
|
|
+ $table->addBehavior('Translate', ['fields' => ['title', 'body']]);
|
|
|
+ $authors = $table->belongsTo('Authors')->target();
|
|
|
+ $authors->addBehavior('Translate', ['fields' => ['name']]);
|
|
|
+
|
|
|
+ $table->locale('eng');
|
|
|
+ $authors->locale('eng');
|
|
|
+
|
|
|
+ $results = $table->find()->contain(['Authors' => function($q) {
|
|
|
+ return $q->select(['id', 'name']);
|
|
|
+ }]);
|
|
|
+
|
|
|
+ debug(json_encode($results->first()->author));
|
|
|
+ }
|
|
|
+
|
|
|
}
|