Fixing issue when Model::$translateTable is set

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8050 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
renan.saddam 2009-02-19 13:45:51 +00:00
parent 82a8599098
commit 52f4cd42db
2 changed files with 28 additions and 0 deletions

View file

@ -370,6 +370,8 @@ class TranslateBehavior extends ModelBehavior {
}
if (!empty($model->translateTable) && $model->translateTable !== $this->runtime[$model->alias]['model']->useTable) {
$this->runtime[$model->alias]['model']->setSource($model->translateTable);
} elseif (empty($model->translateTable) && empty($model->translateModel)) {
$this->runtime[$model->alias]['model']->setSource('i18n');
}
return $this->runtime[$model->alias]['model'];
}

View file

@ -64,6 +64,32 @@ class TranslateTest extends CakeTestCase {
function endTest() {
ClassRegistry::flush();
}
/**
* testTranslateModel method
*
* @access public
* @return void
*/
function testTranslateModel() {
$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');
$TestModel =& new User();
$TestModel->Behaviors->attach('Translate', array('title'));
$this->assertEqual($TestModel->translateModel()->name, 'I18nModel');
$this->assertEqual($TestModel->translateModel()->useTable, 'i18n');
$TestModel =& new TranslatedArticle();
$this->assertEqual($TestModel->translateModel()->name, 'TranslateArticleModel');
$this->assertEqual($TestModel->translateModel()->useTable, 'article_i18n');
$TestModel =& new TranslatedItem();
$this->assertEqual($TestModel->translateModel()->name, 'TranslateTestModel');
$this->assertEqual($TestModel->translateModel()->useTable, 'i18n');
}
/**
* testLocaleFalsePlain method
*