addBehavior('Translate', ['fields' => ['title', 'body']]); $table->locale('eng'); $results = $table->find()->combine('title', 'body', 'id')->toArray(); $expected = [ 1 => ['Title #1' => 'Content #1'], 2 => ['Title #2' => 'Content #2'], 3 => ['Title #3' => 'Content #3'], ]; $this->assertSame($expected, $results); } /** * Tests that overriding fields with the translate behavior works when * using conditions and that all other columns are preserved * * @return void */ public function testFindSingleLocaleWithConditions() { $table = TableRegistry::get('Articles'); $table->addBehavior('Translate'); $table->addBehavior('Translate', ['fields' => ['title', 'body']]); $table->locale('eng'); $results = $table->find() ->where(['Articles.id' => 2]) ->all(); $this->assertCount(1, $results); $row = $results->first(); $expected = [ 'id' => 2, 'title' => 'Title #2', 'body' => 'Content #2', 'author_id' => 3, 'published' => 'Y', '_locale' => 'eng' ]; $this->assertEquals($expected, $row->toArray()); } }