diff --git a/cake/libs/model/behaviors/translate.php b/cake/libs/model/behaviors/translate.php index 24659ef38..1162180ab 100644 --- a/cake/libs/model/behaviors/translate.php +++ b/cake/libs/model/behaviors/translate.php @@ -377,7 +377,8 @@ class TranslateBehavior extends ModelBehavior { } elseif (empty($model->translateTable) && empty($model->translateModel)) { $this->runtime[$model->alias]['model']->setSource('i18n'); } - return $this->runtime[$model->alias]['model']; + $model =& $this->runtime[$model->alias]['model']; + return $model; } /** * Bind translation for fields, optionally with hasMany association for diff --git a/cake/tests/cases/libs/model/behaviors/translate.test.php b/cake/tests/cases/libs/model/behaviors/translate.test.php index 55e13d8af..1231eecb9 100644 --- a/cake/tests/cases/libs/model/behaviors/translate.test.php +++ b/cake/tests/cases/libs/model/behaviors/translate.test.php @@ -74,21 +74,25 @@ class TranslateBehaviorTest extends CakeTestCase { $TestModel =& new Tag(); $TestModel->translateTable = 'another_i18n'; $TestModel->Behaviors->attach('Translate', array('title')); - $this->assertEqual($TestModel->translateModel()->name, 'I18nModel'); - $this->assertEqual($TestModel->translateModel()->useTable, 'another_i18n'); + $translateModel =& $TestModel->Behaviors->Translate->translateModel($TestModel); + $this->assertEqual($translateModel->name, 'I18nModel'); + $this->assertEqual($translateModel->useTable, 'another_i18n'); $TestModel =& new User(); $TestModel->Behaviors->attach('Translate', array('title')); - $this->assertEqual($TestModel->translateModel()->name, 'I18nModel'); - $this->assertEqual($TestModel->translateModel()->useTable, 'i18n'); + $translateModel =& $TestModel->Behaviors->Translate->translateModel($TestModel); + $this->assertEqual($translateModel->name, 'I18nModel'); + $this->assertEqual($translateModel->useTable, 'i18n'); $TestModel =& new TranslatedArticle(); - $this->assertEqual($TestModel->translateModel()->name, 'TranslateArticleModel'); - $this->assertEqual($TestModel->translateModel()->useTable, 'article_i18n'); + $translateModel =& $TestModel->Behaviors->Translate->translateModel($TestModel); + $this->assertEqual($translateModel->name, 'TranslateArticleModel'); + $this->assertEqual($translateModel->useTable, 'article_i18n'); $TestModel =& new TranslatedItem(); - $this->assertEqual($TestModel->translateModel()->name, 'TranslateTestModel'); - $this->assertEqual($TestModel->translateModel()->useTable, 'i18n'); + $translateModel =& $TestModel->Behaviors->Translate->translateModel($TestModel); + $this->assertEqual($translateModel->name, 'TranslateTestModel'); + $this->assertEqual($translateModel->useTable, 'i18n'); } /** * testLocaleFalsePlain method