Fixing TranslateBehavior test to run in php4.

This commit is contained in:
Mark Story 2010-01-26 11:00:37 -05:00
parent 9cbb9d193a
commit c195d654b3
2 changed files with 14 additions and 9 deletions

View file

@ -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

View file

@ -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