mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR More Translatable unit tests
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@70320 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
84a7b17cb4
commit
54811abbd2
@ -41,23 +41,7 @@ class TranslatableTest extends FunctionalTest {
|
|||||||
|
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
function testCreateTranslationOnSiteTree() {
|
|
||||||
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
|
||||||
$translatedPage = $origPage->createTranslation('de');
|
|
||||||
|
|
||||||
$this->assertEquals($translatedPage->Lang, 'de');
|
|
||||||
$this->assertNotEquals($translatedPage->ID, $origPage->ID);
|
|
||||||
$this->assertEquals($translatedPage->OriginalID, $origPage->ID);
|
|
||||||
|
|
||||||
$subsequentTranslatedPage = $origPage->createTranslation('de');
|
|
||||||
$this->assertEquals(
|
|
||||||
$translatedPage->ID,
|
|
||||||
$subsequentTranslatedPage->ID,
|
|
||||||
'Subsequent calls to createTranslation() dont cause new records in database'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testGetOriginalPage() {
|
function testGetOriginalPage() {
|
||||||
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
||||||
$translatedPage = $origPage->createTranslation('de');
|
$translatedPage = $origPage->createTranslation('de');
|
||||||
@ -355,6 +339,40 @@ class TranslatableTest extends FunctionalTest {
|
|||||||
Translatable::set_reading_lang('en');
|
Translatable::set_reading_lang('en');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testTranslatablePropertiesOnSiteTree() {
|
||||||
|
$origObj = $this->objFromFixture('TranslatableTest_Page', 'testpage_en');
|
||||||
|
$translatedObj = $origObj->createTranslation('fr');
|
||||||
|
$translatedObj->TranslatableProperty = 'Fr';
|
||||||
|
$translatedObj->write();
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
$origObj->TranslatableProperty,
|
||||||
|
'En',
|
||||||
|
'Creating a translation doesnt affect database field on original object'
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$translatedObj->TranslatableProperty,
|
||||||
|
'Fr',
|
||||||
|
'Translated object saves database field independently of original object'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testCreateTranslationOnSiteTree() {
|
||||||
|
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
||||||
|
$translatedPage = $origPage->createTranslation('de');
|
||||||
|
|
||||||
|
$this->assertEquals($translatedPage->Lang, 'de');
|
||||||
|
$this->assertNotEquals($translatedPage->ID, $origPage->ID);
|
||||||
|
$this->assertEquals($translatedPage->OriginalID, $origPage->ID);
|
||||||
|
|
||||||
|
$subsequentTranslatedPage = $origPage->createTranslation('de');
|
||||||
|
$this->assertEquals(
|
||||||
|
$translatedPage->ID,
|
||||||
|
$subsequentTranslatedPage->ID,
|
||||||
|
'Subsequent calls to createTranslation() dont cause new records in database'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function testTranslatablePropertiesOnDataObject() {
|
function testTranslatablePropertiesOnDataObject() {
|
||||||
$origObj = $this->objFromFixture('TranslatableTest_DataObject', 'testobject_en');
|
$origObj = $this->objFromFixture('TranslatableTest_DataObject', 'testobject_en');
|
||||||
$translatedObj = $origObj->createTranslation('fr');
|
$translatedObj = $origObj->createTranslation('fr');
|
||||||
@ -483,5 +501,14 @@ class TranslatableTest_Decorator extends DataObjectDecorator implements TestOnly
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TranslatableTest_Page extends Page implements TestOnly {
|
||||||
|
// static $extensions is inherited from SiteTree,
|
||||||
|
// we don't need to explicitly specify the fields
|
||||||
|
|
||||||
|
static $db = array(
|
||||||
|
'TranslatableProperty' => 'Text'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
DataObject::add_extension('TranslatableTest_DataObject', 'TranslatableTest_Decorator');
|
DataObject::add_extension('TranslatableTest_DataObject', 'TranslatableTest_Decorator');
|
||||||
?>
|
?>
|
@ -31,4 +31,9 @@ Page:
|
|||||||
TranslatableTest_DataObject:
|
TranslatableTest_DataObject:
|
||||||
testobject_en:
|
testobject_en:
|
||||||
TranslatableProperty: En
|
TranslatableProperty: En
|
||||||
TranslatableDecoratedProperty: En
|
TranslatableDecoratedProperty: En
|
||||||
|
TranslatableTest_Page:
|
||||||
|
testpage_en:
|
||||||
|
Title: En
|
||||||
|
TranslatableProperty: En
|
||||||
|
URLSegment: testpage-en
|
Loading…
Reference in New Issue
Block a user