mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
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:
parent
82a8599098
commit
52f4cd42db
2 changed files with 28 additions and 0 deletions
|
@ -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'];
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue