2009-01-10 13:38:50 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2009-04-01 18:35:32 +02:00
|
|
|
* @todo Test Versioned getters
|
|
|
|
*
|
2009-01-10 13:38:50 +01:00
|
|
|
* @package sapphire
|
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
class TranslatableTest extends FunctionalTest {
|
|
|
|
|
|
|
|
static $fixture_file = 'sapphire/tests/model/TranslatableTest.yml';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @todo Necessary because of monolithic Translatable design
|
|
|
|
*/
|
2009-04-22 05:22:09 +02:00
|
|
|
static protected $origTranslatableSettings = array();
|
2009-01-10 13:38:50 +01:00
|
|
|
|
2009-04-22 05:22:09 +02:00
|
|
|
static function set_up_once() {
|
2009-01-13 23:28:24 +01:00
|
|
|
// needs to recreate the database schema with language properties
|
2009-01-10 13:38:50 +01:00
|
|
|
self::kill_temp_db();
|
2009-04-22 05:22:09 +02:00
|
|
|
|
2009-04-01 18:35:32 +02:00
|
|
|
// store old defaults
|
2009-04-22 05:22:09 +02:00
|
|
|
self::$origTranslatableSettings['has_extension'] = singleton('SiteTree')->hasExtension('Translatable');
|
|
|
|
self::$origTranslatableSettings['default_locale'] = Translatable::default_locale();
|
|
|
|
|
2009-04-01 18:35:32 +02:00
|
|
|
// overwrite locale
|
|
|
|
Translatable::set_default_locale("en_US");
|
|
|
|
|
2009-01-13 05:34:45 +01:00
|
|
|
// refresh the decorated statics - different fields in $db with Translatable enabled
|
2009-04-22 05:22:09 +02:00
|
|
|
if(!self::$origTranslatableSettings['has_extension']) Object::add_extension('SiteTree', 'Translatable');
|
2009-04-01 18:35:32 +02:00
|
|
|
Object::add_extension('TranslatableTest_DataObject', 'Translatable');
|
2009-04-22 05:22:09 +02:00
|
|
|
|
2009-04-01 18:35:32 +02:00
|
|
|
// clear singletons, they're caching old extension info which is used in DatabaseAdmin->doBuild()
|
|
|
|
global $_SINGLETONS;
|
|
|
|
$_SINGLETONS = array();
|
2009-04-22 05:22:09 +02:00
|
|
|
|
2009-04-01 18:35:32 +02:00
|
|
|
// recreate database with new settings
|
2009-01-13 05:34:45 +01:00
|
|
|
$dbname = self::create_temp_db();
|
|
|
|
DB::set_alternative_database_name($dbname);
|
2009-04-01 18:35:32 +02:00
|
|
|
|
2009-04-22 05:22:09 +02:00
|
|
|
parent::set_up_once();
|
2009-01-10 13:38:50 +01:00
|
|
|
}
|
|
|
|
|
2009-04-22 05:22:09 +02:00
|
|
|
static function tear_down_once() {
|
|
|
|
if(!self::$origTranslatableSettings['has_extension']) Object::remove_extension('SiteTree', 'Translatable');
|
2009-01-10 13:38:50 +01:00
|
|
|
|
2009-04-22 05:22:09 +02:00
|
|
|
Translatable::set_default_locale(self::$origTranslatableSettings['default_locale']);
|
2009-05-17 07:36:01 +02:00
|
|
|
Translatable::set_current_locale(self::$origTranslatableSettings['default_locale']);
|
2009-01-10 13:38:50 +01:00
|
|
|
|
|
|
|
self::kill_temp_db();
|
|
|
|
self::create_temp_db();
|
|
|
|
|
2009-04-22 05:22:09 +02:00
|
|
|
parent::tear_down_once();
|
2009-01-10 13:38:50 +01:00
|
|
|
}
|
2009-05-14 07:16:49 +02:00
|
|
|
|
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
// whenever a translation is created, canTranslate() is checked
|
|
|
|
$cmseditor = $this->objFromFixture('Member', 'cmseditor');
|
|
|
|
$cmseditor->logIn();
|
|
|
|
}
|
2009-10-05 12:33:36 +02:00
|
|
|
|
2009-03-18 17:13:40 +01:00
|
|
|
function testTranslationGroups() {
|
|
|
|
// first in french
|
|
|
|
$frPage = new SiteTree();
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$frPage->Locale = 'fr_FR';
|
2009-03-18 17:13:40 +01:00
|
|
|
$frPage->write();
|
|
|
|
|
|
|
|
// second in english (from french "original")
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$enPage = $frPage->createTranslation('en_US');
|
2009-03-18 17:13:40 +01:00
|
|
|
|
|
|
|
// third in spanish (from the english translation)
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$esPage = $enPage->createTranslation('es_ES');
|
2009-03-18 17:13:40 +01:00
|
|
|
|
|
|
|
// test french
|
|
|
|
$this->assertEquals(
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$frPage->getTranslations()->column('Locale'),
|
|
|
|
array('en_US','es_ES')
|
2009-03-18 17:13:40 +01:00
|
|
|
);
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$this->assertNotNull($frPage->getTranslation('en_US'));
|
2009-03-18 17:13:40 +01:00
|
|
|
$this->assertEquals(
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$frPage->getTranslation('en_US')->ID,
|
2009-03-18 17:13:40 +01:00
|
|
|
$enPage->ID
|
|
|
|
);
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$this->assertNotNull($frPage->getTranslation('es_ES'));
|
2009-03-18 17:13:40 +01:00
|
|
|
$this->assertEquals(
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$frPage->getTranslation('es_ES')->ID,
|
2009-03-18 17:13:40 +01:00
|
|
|
$esPage->ID
|
|
|
|
);
|
|
|
|
|
|
|
|
// test english
|
|
|
|
$this->assertEquals(
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$enPage->getTranslations()->column('Locale'),
|
|
|
|
array('fr_FR','es_ES')
|
2009-03-18 17:13:40 +01:00
|
|
|
);
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$this->assertNotNull($frPage->getTranslation('fr_FR'));
|
2009-03-18 17:13:40 +01:00
|
|
|
$this->assertEquals(
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$enPage->getTranslation('fr_FR')->ID,
|
2009-03-18 17:13:40 +01:00
|
|
|
$frPage->ID
|
|
|
|
);
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$this->assertNotNull($frPage->getTranslation('es_ES'));
|
2009-03-18 17:13:40 +01:00
|
|
|
$this->assertEquals(
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$enPage->getTranslation('es_ES')->ID,
|
2009-03-18 17:13:40 +01:00
|
|
|
$esPage->ID
|
|
|
|
);
|
2009-01-13 05:34:45 +01:00
|
|
|
|
2009-03-18 17:13:40 +01:00
|
|
|
// test spanish
|
|
|
|
$this->assertEquals(
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$esPage->getTranslations()->column('Locale'),
|
|
|
|
array('fr_FR','en_US')
|
2009-03-18 17:13:40 +01:00
|
|
|
);
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$this->assertNotNull($esPage->getTranslation('fr_FR'));
|
2009-03-18 17:13:40 +01:00
|
|
|
$this->assertEquals(
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$esPage->getTranslation('fr_FR')->ID,
|
2009-03-18 17:13:40 +01:00
|
|
|
$frPage->ID
|
|
|
|
);
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$this->assertNotNull($esPage->getTranslation('en_US'));
|
2009-03-18 17:13:40 +01:00
|
|
|
$this->assertEquals(
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$esPage->getTranslation('en_US')->ID,
|
2009-03-18 17:13:40 +01:00
|
|
|
$enPage->ID
|
|
|
|
);
|
2009-01-13 05:34:45 +01:00
|
|
|
}
|
2009-06-15 07:02:43 +02:00
|
|
|
|
|
|
|
function testTranslationGroupNotRemovedWhenSiteTreeUnpublished() {
|
|
|
|
$enPage = new Page();
|
|
|
|
$enPage->Locale = 'en_US';
|
|
|
|
$enPage->write();
|
|
|
|
$enPage->publish('Stage', 'Live');
|
|
|
|
$enTranslationGroup = $enPage->getTranslationGroup();
|
|
|
|
|
|
|
|
$frPage = $enPage->createTranslation('fr_FR');
|
|
|
|
$frPage->write();
|
|
|
|
$frPage->publish('Stage', 'Live');
|
|
|
|
$frTranslationGroup = $frPage->getTranslationGroup();
|
|
|
|
|
|
|
|
$enPage->doUnpublish();
|
|
|
|
$this->assertEquals($enPage->getTranslationGroup(), $enTranslationGroup);
|
|
|
|
|
|
|
|
$frPage->doUnpublish();
|
|
|
|
$this->assertEquals($frPage->getTranslationGroup(), $frTranslationGroup);
|
|
|
|
}
|
2009-10-05 12:33:36 +02:00
|
|
|
|
2009-01-13 05:34:45 +01:00
|
|
|
function testGetTranslationOnSiteTree() {
|
|
|
|
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
2009-04-01 18:35:32 +02:00
|
|
|
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$translatedPage = $origPage->createTranslation('fr_FR');
|
|
|
|
$getTranslationPage = $origPage->getTranslation('fr_FR');
|
2009-10-05 12:33:36 +02:00
|
|
|
|
2009-01-13 05:34:45 +01:00
|
|
|
$this->assertNotNull($getTranslationPage);
|
|
|
|
$this->assertEquals($getTranslationPage->ID, $translatedPage->ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
function testGetTranslatedLanguages() {
|
|
|
|
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
|
|
|
|
|
|
|
// through createTranslation()
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$translationAf = $origPage->createTranslation('af_ZA');
|
2009-01-13 05:34:45 +01:00
|
|
|
|
|
|
|
// create a new language on an unrelated page which shouldnt be returned from $origPage
|
|
|
|
$otherPage = new Page();
|
|
|
|
$otherPage->write();
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$otherTranslationEs = $otherPage->createTranslation('es_ES');
|
2009-01-13 05:34:45 +01:00
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
$origPage->getTranslatedLangs(),
|
|
|
|
array(
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
'af_ZA',
|
|
|
|
//'en_US', // default language is not included
|
2009-01-13 05:34:45 +01:00
|
|
|
),
|
|
|
|
'Language codes are returned specifically for the queried page through getTranslatedLangs()'
|
|
|
|
);
|
|
|
|
|
|
|
|
$pageWithoutTranslations = new Page();
|
|
|
|
$pageWithoutTranslations->write();
|
|
|
|
$this->assertEquals(
|
|
|
|
$pageWithoutTranslations->getTranslatedLangs(),
|
|
|
|
array(),
|
|
|
|
'A page without translations returns empty array through getTranslatedLangs(), ' .
|
|
|
|
'even if translations for other pages exist in the database'
|
|
|
|
);
|
2009-03-18 17:13:40 +01:00
|
|
|
|
|
|
|
// manual creation of page without an original link
|
|
|
|
$translationDeWithoutOriginal = new Page();
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$translationDeWithoutOriginal->Locale = 'de_DE';
|
2009-03-18 17:13:40 +01:00
|
|
|
$translationDeWithoutOriginal->write();
|
|
|
|
$this->assertEquals(
|
|
|
|
$translationDeWithoutOriginal->getTranslatedLangs(),
|
|
|
|
array(),
|
|
|
|
'A translated page without an original doesn\'t return anything through getTranslatedLang()'
|
|
|
|
);
|
2009-01-13 05:34:45 +01:00
|
|
|
}
|
2009-10-05 12:33:36 +02:00
|
|
|
|
2009-05-04 10:48:14 +02:00
|
|
|
function testTranslationCantHaveSameURLSegmentAcrossLanguages() {
|
2009-01-13 05:34:45 +01:00
|
|
|
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$translatedPage = $origPage->createTranslation('de_DE');
|
2009-01-13 05:34:45 +01:00
|
|
|
$translatedPage->URLSegment = 'testpage';
|
2009-05-04 10:48:14 +02:00
|
|
|
$translatedPage->write();
|
2009-10-05 12:33:36 +02:00
|
|
|
|
2009-05-04 10:48:14 +02:00
|
|
|
$this->assertNotEquals($origPage->URLSegment, $translatedPage->URLSegment);
|
2009-01-10 13:38:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function testUpdateCMSFieldsOnSiteTree() {
|
2009-01-13 05:34:45 +01:00
|
|
|
$pageOrigLang = $this->objFromFixture('Page', 'testpage_en');
|
2009-01-10 13:38:50 +01:00
|
|
|
|
|
|
|
// first test with default language
|
|
|
|
$fields = $pageOrigLang->getCMSFields();
|
|
|
|
$this->assertType(
|
|
|
|
'TextField',
|
|
|
|
$fields->dataFieldByName('Title'),
|
|
|
|
'Translatable doesnt modify fields if called in default language (e.g. "non-translation mode")'
|
|
|
|
);
|
|
|
|
$this->assertNull(
|
|
|
|
$fields->dataFieldByName('Title_original'),
|
|
|
|
'Translatable doesnt modify fields if called in default language (e.g. "non-translation mode")'
|
|
|
|
);
|
|
|
|
|
|
|
|
// then in "translation mode"
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$pageTranslated = $pageOrigLang->createTranslation('fr_FR');
|
2009-01-10 13:38:50 +01:00
|
|
|
$fields = $pageTranslated->getCMSFields();
|
|
|
|
$this->assertType(
|
|
|
|
'TextField',
|
|
|
|
$fields->dataFieldByName('Title'),
|
|
|
|
'Translatable leaves original formfield intact in "translation mode"'
|
|
|
|
);
|
|
|
|
$readonlyField = $fields->dataFieldByName('Title')->performReadonlyTransformation();
|
|
|
|
$this->assertType(
|
|
|
|
$readonlyField->class,
|
|
|
|
$fields->dataFieldByName('Title_original'),
|
|
|
|
'Translatable adds the original value as a ReadonlyField in "translation mode"'
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
2009-01-14 05:10:54 +01:00
|
|
|
|
|
|
|
function testDataObjectGetWithReadingLanguage() {
|
|
|
|
$origTestPage = $this->objFromFixture('Page', 'testpage_en');
|
|
|
|
$otherTestPage = $this->objFromFixture('Page', 'othertestpage_en');
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$translatedPage = $origTestPage->createTranslation('de_DE');
|
2009-01-14 05:10:54 +01:00
|
|
|
|
|
|
|
// test in default language
|
|
|
|
$resultPagesDefaultLang = DataObject::get(
|
|
|
|
'Page',
|
|
|
|
sprintf("\"SiteTree\".\"MenuTitle\" = '%s'", 'A Testpage')
|
|
|
|
);
|
|
|
|
$this->assertEquals($resultPagesDefaultLang->Count(), 2);
|
|
|
|
$this->assertContains($origTestPage->ID, $resultPagesDefaultLang->column('ID'));
|
|
|
|
$this->assertContains($otherTestPage->ID, $resultPagesDefaultLang->column('ID'));
|
|
|
|
$this->assertNotContains($translatedPage->ID, $resultPagesDefaultLang->column('ID'));
|
|
|
|
|
|
|
|
// test in custom language
|
2009-05-17 07:36:01 +02:00
|
|
|
Translatable::set_current_locale('de_DE');
|
2009-01-14 05:10:54 +01:00
|
|
|
$resultPagesCustomLang = DataObject::get(
|
|
|
|
'Page',
|
|
|
|
sprintf("\"SiteTree\".\"MenuTitle\" = '%s'", 'A Testpage')
|
|
|
|
);
|
|
|
|
$this->assertEquals($resultPagesCustomLang->Count(), 1);
|
|
|
|
$this->assertNotContains($origTestPage->ID, $resultPagesCustomLang->column('ID'));
|
|
|
|
$this->assertNotContains($otherTestPage->ID, $resultPagesCustomLang->column('ID'));
|
|
|
|
// casting as a workaround for types not properly set on duplicated dataobjects from createTranslation()
|
|
|
|
$this->assertContains((string)$translatedPage->ID, $resultPagesCustomLang->column('ID'));
|
|
|
|
|
2009-05-17 07:36:01 +02:00
|
|
|
Translatable::set_current_locale('en_US');
|
2009-01-14 05:10:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function testDataObjectGetByIdWithReadingLanguage() {
|
|
|
|
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$translatedPage = $origPage->createTranslation('de_DE');
|
2009-01-14 05:10:54 +01:00
|
|
|
$compareOrigPage = DataObject::get_by_id('Page', $origPage->ID);
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
$origPage->ID,
|
|
|
|
$compareOrigPage->ID,
|
|
|
|
'DataObject::get_by_id() should work independently of the reading language'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function testDataObjectGetOneWithReadingLanguage() {
|
|
|
|
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$translatedPage = $origPage->createTranslation('de_DE');
|
2009-01-14 05:10:54 +01:00
|
|
|
|
|
|
|
// running the same query twice with different
|
2009-05-17 07:36:01 +02:00
|
|
|
Translatable::set_current_locale('de_DE');
|
2009-01-14 05:10:54 +01:00
|
|
|
$compareTranslatedPage = DataObject::get_one(
|
|
|
|
'Page',
|
|
|
|
sprintf("\"SiteTree\".\"Title\" = '%s'", $translatedPage->Title)
|
|
|
|
);
|
|
|
|
$this->assertNotNull($compareTranslatedPage);
|
|
|
|
$this->assertEquals(
|
|
|
|
$translatedPage->ID,
|
|
|
|
$compareTranslatedPage->ID,
|
|
|
|
"Translated page is found through get_one() when reading lang is not the default language"
|
|
|
|
);
|
|
|
|
|
|
|
|
// reset language to default
|
2009-05-17 07:36:01 +02:00
|
|
|
Translatable::set_current_locale('en_US');
|
2009-01-14 05:10:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function testModifyTranslationWithDefaultReadingLang() {
|
|
|
|
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$translatedPage = $origPage->createTranslation('de_DE');
|
2009-01-14 05:10:54 +01:00
|
|
|
|
2009-05-17 07:36:01 +02:00
|
|
|
Translatable::set_current_locale('en_US');
|
2009-01-14 05:10:54 +01:00
|
|
|
$translatedPage->Title = 'De Modified';
|
|
|
|
$translatedPage->write();
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$savedTranslatedPage = $origPage->getTranslation('de_DE');
|
2009-01-14 05:10:54 +01:00
|
|
|
$this->assertEquals(
|
|
|
|
$savedTranslatedPage->Title,
|
|
|
|
'De Modified',
|
|
|
|
'Modifying a record in language which is not the reading language should still write the record correctly'
|
|
|
|
);
|
|
|
|
$this->assertEquals(
|
|
|
|
$origPage->Title,
|
|
|
|
'Home',
|
|
|
|
'Modifying a record in language which is not the reading language does not modify the original record'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function testSiteTreePublication() {
|
|
|
|
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$translatedPage = $origPage->createTranslation('de_DE');
|
2009-01-14 05:10:54 +01:00
|
|
|
|
2009-05-17 07:36:01 +02:00
|
|
|
Translatable::set_current_locale('en_US');
|
2009-01-14 05:10:54 +01:00
|
|
|
$origPage->Title = 'En Modified';
|
|
|
|
$origPage->write();
|
|
|
|
// modifying a record in language which is not the reading language should still write the record correctly
|
|
|
|
$translatedPage->Title = 'De Modified';
|
|
|
|
$translatedPage->write();
|
|
|
|
$origPage->publish('Stage', 'Live');
|
2009-09-17 02:27:16 +02:00
|
|
|
$liveOrigPage = Versioned::get_one_by_stage('Page', 'Live', "\"SiteTree\".\"ID\" = {$origPage->ID}");
|
2009-01-14 05:10:54 +01:00
|
|
|
$this->assertEquals(
|
|
|
|
$liveOrigPage->Title,
|
|
|
|
'En Modified',
|
|
|
|
'Publishing a record in its original language publshes correct properties'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function testDeletingTranslationKeepsOriginal() {
|
|
|
|
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$translatedPage = $origPage->createTranslation('de_DE');
|
2009-01-14 05:10:54 +01:00
|
|
|
$translatedPageID = $translatedPage->ID;
|
|
|
|
$translatedPage->delete();
|
|
|
|
|
|
|
|
$translatedPage->flushCache();
|
|
|
|
$origPage->flushCache();
|
2009-10-05 12:33:36 +02:00
|
|
|
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$this->assertNull($origPage->getTranslation('de_DE'));
|
2009-01-14 05:10:54 +01:00
|
|
|
$this->assertNotNull(DataObject::get_by_id('Page', $origPage->ID));
|
|
|
|
}
|
|
|
|
|
2009-01-15 06:56:25 +01:00
|
|
|
function testHierarchyChildren() {
|
|
|
|
$parentPage = $this->objFromFixture('Page', 'parent');
|
|
|
|
$child1Page = $this->objFromFixture('Page', 'child1');
|
|
|
|
$child2Page = $this->objFromFixture('Page', 'child2');
|
|
|
|
$child3Page = $this->objFromFixture('Page', 'child3');
|
2009-05-12 02:46:57 +02:00
|
|
|
$grandchildPage = $this->objFromFixture('Page', 'grandchild1');
|
2009-01-15 06:56:25 +01:00
|
|
|
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$parentPageTranslated = $parentPage->createTranslation('de_DE');
|
2009-03-20 08:58:52 +01:00
|
|
|
$child4PageTranslated = new SiteTree();
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$child4PageTranslated->Locale = 'de_DE';
|
2009-03-20 08:58:52 +01:00
|
|
|
$child4PageTranslated->ParentID = $parentPageTranslated->ID;
|
|
|
|
$child4PageTranslated->write();
|
2009-01-15 06:56:25 +01:00
|
|
|
|
2009-05-17 07:36:01 +02:00
|
|
|
Translatable::set_current_locale('en_US');
|
2009-01-15 06:56:25 +01:00
|
|
|
$this->assertEquals(
|
|
|
|
$parentPage->Children()->column('ID'),
|
|
|
|
array(
|
|
|
|
$child1Page->ID,
|
|
|
|
$child2Page->ID,
|
|
|
|
$child3Page->ID
|
|
|
|
),
|
|
|
|
"Showing Children() in default language doesnt show children in other languages"
|
|
|
|
);
|
|
|
|
|
2009-05-17 07:36:01 +02:00
|
|
|
Translatable::set_current_locale('de_DE');
|
2009-01-15 06:56:25 +01:00
|
|
|
$parentPage->flushCache();
|
|
|
|
$this->assertEquals(
|
2009-03-20 08:58:52 +01:00
|
|
|
$parentPageTranslated->Children()->column('ID'),
|
|
|
|
array($child4PageTranslated->ID),
|
2009-01-15 06:56:25 +01:00
|
|
|
"Showing Children() in translation mode doesnt show children in default languages"
|
|
|
|
);
|
|
|
|
|
|
|
|
// reset language
|
2009-05-17 07:36:01 +02:00
|
|
|
Translatable::set_current_locale('en_US');
|
2009-01-15 06:56:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function testHierarchyLiveStageChildren() {
|
|
|
|
$parentPage = $this->objFromFixture('Page', 'parent');
|
|
|
|
$child1Page = $this->objFromFixture('Page', 'child1');
|
|
|
|
$child1Page->publish('Stage', 'Live');
|
|
|
|
$child2Page = $this->objFromFixture('Page', 'child2');
|
|
|
|
$child3Page = $this->objFromFixture('Page', 'child3');
|
2009-05-12 02:46:57 +02:00
|
|
|
$grandchildPage = $this->objFromFixture('Page', 'grandchild1');
|
2009-01-15 06:56:25 +01:00
|
|
|
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$parentPageTranslated = $parentPage->createTranslation('de_DE');
|
2009-03-20 08:58:52 +01:00
|
|
|
|
|
|
|
$child4PageTranslated = new SiteTree();
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$child4PageTranslated->Locale = 'de_DE';
|
2009-03-20 08:58:52 +01:00
|
|
|
$child4PageTranslated->ParentID = $parentPageTranslated->ID;
|
|
|
|
$child4PageTranslated->write();
|
|
|
|
$child4PageTranslated->publish('Stage', 'Live');
|
|
|
|
|
|
|
|
$child5PageTranslated = new SiteTree();
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$child5PageTranslated->Locale = 'de_DE';
|
2009-03-20 08:58:52 +01:00
|
|
|
$child5PageTranslated->ParentID = $parentPageTranslated->ID;
|
|
|
|
$child5PageTranslated->write();
|
2009-01-15 06:56:25 +01:00
|
|
|
|
2009-05-17 07:36:01 +02:00
|
|
|
Translatable::set_current_locale('en_US');
|
2009-03-20 08:58:52 +01:00
|
|
|
$this->assertNotNull($parentPage->liveChildren());
|
2009-01-15 06:56:25 +01:00
|
|
|
$this->assertEquals(
|
|
|
|
$parentPage->liveChildren()->column('ID'),
|
|
|
|
array(
|
|
|
|
$child1Page->ID
|
|
|
|
),
|
|
|
|
"Showing liveChildren() in default language doesnt show children in other languages"
|
|
|
|
);
|
2009-03-20 08:58:52 +01:00
|
|
|
$this->assertNotNull($parentPage->stageChildren());
|
2009-01-15 06:56:25 +01:00
|
|
|
$this->assertEquals(
|
|
|
|
$parentPage->stageChildren()->column('ID'),
|
|
|
|
array(
|
|
|
|
$child1Page->ID,
|
|
|
|
$child2Page->ID,
|
|
|
|
$child3Page->ID
|
|
|
|
),
|
|
|
|
"Showing stageChildren() in default language doesnt show children in other languages"
|
|
|
|
);
|
|
|
|
|
2009-05-17 07:36:01 +02:00
|
|
|
Translatable::set_current_locale('de_DE');
|
2009-01-15 06:56:25 +01:00
|
|
|
$parentPage->flushCache();
|
2009-03-20 08:58:52 +01:00
|
|
|
$this->assertNotNull($parentPageTranslated->liveChildren());
|
2009-01-15 06:56:25 +01:00
|
|
|
$this->assertEquals(
|
2009-03-20 08:58:52 +01:00
|
|
|
$parentPageTranslated->liveChildren()->column('ID'),
|
|
|
|
array($child4PageTranslated->ID),
|
2009-01-15 06:56:25 +01:00
|
|
|
"Showing liveChildren() in translation mode doesnt show children in default languages"
|
|
|
|
);
|
2009-03-20 08:58:52 +01:00
|
|
|
$this->assertNotNull($parentPageTranslated->stageChildren());
|
2009-01-15 06:56:25 +01:00
|
|
|
$this->assertEquals(
|
2009-03-20 08:58:52 +01:00
|
|
|
$parentPageTranslated->stageChildren()->column('ID'),
|
2009-01-15 06:56:25 +01:00
|
|
|
array(
|
2009-03-20 08:58:52 +01:00
|
|
|
$child4PageTranslated->ID,
|
|
|
|
$child5PageTranslated->ID,
|
2009-01-15 06:56:25 +01:00
|
|
|
),
|
|
|
|
"Showing stageChildren() in translation mode doesnt show children in default languages"
|
|
|
|
);
|
|
|
|
|
|
|
|
// reset language
|
2009-05-17 07:36:01 +02:00
|
|
|
Translatable::set_current_locale('en_US');
|
2009-01-15 06:56:25 +01:00
|
|
|
}
|
|
|
|
|
2009-01-18 23:48:45 +01:00
|
|
|
function testTranslatablePropertiesOnSiteTree() {
|
|
|
|
$origObj = $this->objFromFixture('TranslatableTest_Page', 'testpage_en');
|
2009-04-01 18:35:32 +02:00
|
|
|
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$translatedObj = $origObj->createTranslation('fr_FR');
|
|
|
|
$translatedObj->TranslatableProperty = 'fr_FR';
|
2009-01-18 23:48:45 +01:00
|
|
|
$translatedObj->write();
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
$origObj->TranslatableProperty,
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
'en_US',
|
2009-01-18 23:48:45 +01:00
|
|
|
'Creating a translation doesnt affect database field on original object'
|
|
|
|
);
|
|
|
|
$this->assertEquals(
|
|
|
|
$translatedObj->TranslatableProperty,
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
'fr_FR',
|
2009-01-18 23:48:45 +01:00
|
|
|
'Translated object saves database field independently of original object'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function testCreateTranslationOnSiteTree() {
|
|
|
|
$origPage = $this->objFromFixture('Page', 'testpage_en');
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$translatedPage = $origPage->createTranslation('de_DE');
|
2009-10-05 12:33:36 +02:00
|
|
|
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$this->assertEquals($translatedPage->Locale, 'de_DE');
|
2009-01-18 23:48:45 +01:00
|
|
|
$this->assertNotEquals($translatedPage->ID, $origPage->ID);
|
2009-10-05 12:33:36 +02:00
|
|
|
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$subsequentTranslatedPage = $origPage->createTranslation('de_DE');
|
2009-01-18 23:48:45 +01:00
|
|
|
$this->assertEquals(
|
|
|
|
$translatedPage->ID,
|
|
|
|
$subsequentTranslatedPage->ID,
|
|
|
|
'Subsequent calls to createTranslation() dont cause new records in database'
|
|
|
|
);
|
|
|
|
}
|
2009-10-05 12:33:36 +02:00
|
|
|
|
2009-01-15 06:56:25 +01:00
|
|
|
function testTranslatablePropertiesOnDataObject() {
|
|
|
|
$origObj = $this->objFromFixture('TranslatableTest_DataObject', 'testobject_en');
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$translatedObj = $origObj->createTranslation('fr_FR');
|
|
|
|
$translatedObj->TranslatableProperty = 'fr_FR';
|
|
|
|
$translatedObj->TranslatableDecoratedProperty = 'fr_FR';
|
2009-01-15 06:56:25 +01:00
|
|
|
$translatedObj->write();
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
$origObj->TranslatableProperty,
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
'en_US',
|
2009-01-15 06:56:25 +01:00
|
|
|
'Creating a translation doesnt affect database field on original object'
|
|
|
|
);
|
|
|
|
$this->assertEquals(
|
|
|
|
$origObj->TranslatableDecoratedProperty,
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
'en_US',
|
2009-01-15 06:56:25 +01:00
|
|
|
'Creating a translation doesnt affect decorated database field on original object'
|
|
|
|
);
|
|
|
|
$this->assertEquals(
|
|
|
|
$translatedObj->TranslatableProperty,
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
'fr_FR',
|
2009-01-15 06:56:25 +01:00
|
|
|
'Translated object saves database field independently of original object'
|
|
|
|
);
|
|
|
|
$this->assertEquals(
|
|
|
|
$translatedObj->TranslatableDecoratedProperty,
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
'fr_FR',
|
2009-01-15 06:56:25 +01:00
|
|
|
'Translated object saves decorated database field independently of original object'
|
|
|
|
);
|
2009-01-14 05:10:54 +01:00
|
|
|
}
|
2009-01-16 05:14:34 +01:00
|
|
|
|
2009-03-18 17:13:40 +01:00
|
|
|
function testCreateTranslationWithoutOriginal() {
|
|
|
|
$origParentPage = $this->objFromFixture('Page', 'testpage_en');
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$translatedParentPage = $origParentPage->createTranslation('de_DE');
|
2009-10-05 12:33:36 +02:00
|
|
|
|
2009-03-18 17:13:40 +01:00
|
|
|
$translatedPageWithoutOriginal = new SiteTree();
|
|
|
|
$translatedPageWithoutOriginal->ParentID = $translatedParentPage->ID;
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$translatedPageWithoutOriginal->Locale = 'de_DE';
|
2009-03-18 17:13:40 +01:00
|
|
|
$translatedPageWithoutOriginal->write();
|
2009-10-05 12:33:36 +02:00
|
|
|
|
2009-05-17 07:36:01 +02:00
|
|
|
Translatable::set_current_locale('de_DE');
|
2009-03-18 17:13:40 +01:00
|
|
|
$this->assertEquals(
|
|
|
|
$translatedParentPage->stageChildren()->column('ID'),
|
|
|
|
array(
|
|
|
|
$translatedPageWithoutOriginal->ID
|
|
|
|
),
|
|
|
|
"Children() still works on a translated page even if no translation group is set"
|
|
|
|
);
|
|
|
|
|
2009-05-17 07:36:01 +02:00
|
|
|
Translatable::set_current_locale('en_US');
|
2009-03-18 17:13:40 +01:00
|
|
|
}
|
|
|
|
|
2009-01-16 05:14:34 +01:00
|
|
|
function testCreateTranslationTranslatesUntranslatedParents() {
|
|
|
|
$parentPage = $this->objFromFixture('Page', 'parent');
|
|
|
|
$child1Page = $this->objFromFixture('Page', 'child1');
|
|
|
|
$child1PageOrigID = $child1Page->ID;
|
2009-05-12 02:46:57 +02:00
|
|
|
$grandChild1Page = $this->objFromFixture('Page', 'grandchild1');
|
|
|
|
$grandChild2Page = $this->objFromFixture('Page', 'grandchild2');
|
2009-10-05 12:33:36 +02:00
|
|
|
|
2009-05-12 02:46:57 +02:00
|
|
|
$this->assertFalse($grandChild1Page->hasTranslation('de_DE'));
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$this->assertFalse($child1Page->hasTranslation('de_DE'));
|
|
|
|
$this->assertFalse($parentPage->hasTranslation('de_DE'));
|
2009-10-05 12:33:36 +02:00
|
|
|
|
2009-05-12 02:46:57 +02:00
|
|
|
$translatedGrandChild1Page = $grandChild1Page->createTranslation('de_DE');
|
|
|
|
$translatedGrandChild2Page = $grandChild2Page->createTranslation('de_DE');
|
|
|
|
$translatedChildPage = $child1Page->getTranslation('de_DE');
|
|
|
|
$translatedParentPage = $parentPage->getTranslation('de_DE');
|
2009-10-05 12:33:36 +02:00
|
|
|
|
2009-05-12 02:46:57 +02:00
|
|
|
$this->assertTrue($grandChild1Page->hasTranslation('de_DE'));
|
|
|
|
$this->assertEquals($translatedGrandChild1Page->ParentID, $translatedChildPage->ID);
|
2009-10-05 12:33:36 +02:00
|
|
|
|
2009-05-12 02:46:57 +02:00
|
|
|
$this->assertTrue($grandChild2Page->hasTranslation('de_DE'));
|
|
|
|
$this->assertEquals($translatedGrandChild2Page->ParentID, $translatedChildPage->ID);
|
2009-10-05 12:33:36 +02:00
|
|
|
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$this->assertTrue($child1Page->hasTranslation('de_DE'));
|
2009-05-12 02:46:57 +02:00
|
|
|
$this->assertEquals($translatedChildPage->ParentID, $translatedParentPage->ID);
|
2009-10-05 12:33:36 +02:00
|
|
|
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$this->assertTrue($parentPage->hasTranslation('de_DE'));
|
2009-01-16 05:14:34 +01:00
|
|
|
}
|
2009-10-05 12:33:36 +02:00
|
|
|
|
2009-01-16 05:14:34 +01:00
|
|
|
function testHierarchyAllChildrenIncludingDeleted() {
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
// Original tree in 'en_US':
|
2009-03-18 17:13:40 +01:00
|
|
|
// parent
|
|
|
|
// child1 (Live only, deleted from stage)
|
|
|
|
// child2 (Stage only, never published)
|
|
|
|
// child3 (Stage only, never published, untranslated)
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
// Translated tree in 'de_DE':
|
2009-03-18 17:13:40 +01:00
|
|
|
// parent
|
|
|
|
// child1 (Live only, deleted from stage)
|
|
|
|
// child2 (Stage only)
|
|
|
|
|
|
|
|
// Create parent
|
2009-01-16 05:14:34 +01:00
|
|
|
$parentPage = $this->objFromFixture('Page', 'parent');
|
2009-03-18 17:13:40 +01:00
|
|
|
$parentPageID = $parentPage->ID;
|
|
|
|
|
|
|
|
// Create parent translation
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$translatedParentPage = $parentPage->createTranslation('de_DE');
|
2009-03-18 17:13:40 +01:00
|
|
|
$translatedParentPageID = $translatedParentPage->ID;
|
|
|
|
|
|
|
|
// Create child1
|
2009-01-16 05:14:34 +01:00
|
|
|
$child1Page = $this->objFromFixture('Page', 'child1');
|
2009-03-18 17:13:40 +01:00
|
|
|
$child1PageID = $child1Page->ID;
|
2009-01-16 05:14:34 +01:00
|
|
|
$child1Page->publish('Stage', 'Live');
|
|
|
|
|
2009-03-18 17:13:40 +01:00
|
|
|
// Create child1 translation
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$child1PageTranslated = $child1Page->createTranslation('de_DE');
|
2009-03-18 17:13:40 +01:00
|
|
|
$child1PageTranslatedID = $child1PageTranslated->ID;
|
2009-01-16 05:14:34 +01:00
|
|
|
$child1PageTranslated->publish('Stage', 'Live');
|
2009-03-18 17:13:40 +01:00
|
|
|
$child1PageTranslated->deleteFromStage('Stage'); // deleted from stage only, record still exists on live
|
|
|
|
$child1Page->deleteFromStage('Stage'); // deleted from stage only, record still exists on live
|
|
|
|
|
|
|
|
// Create child2
|
|
|
|
$child2Page = $this->objFromFixture('Page', 'child2');
|
|
|
|
$child2PageID = $child2Page->ID;
|
|
|
|
|
|
|
|
// Create child2 translation
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$child2PageTranslated = $child2Page->createTranslation('de_DE');
|
2009-03-18 17:13:40 +01:00
|
|
|
$child2PageTranslatedID = $child2PageTranslated->ID;
|
|
|
|
|
|
|
|
// Create child3
|
|
|
|
$child3Page = $this->objFromFixture('Page', 'child3');
|
|
|
|
$child3PageID = $child3Page->ID;
|
2009-01-16 05:14:34 +01:00
|
|
|
|
|
|
|
// on original parent in default language
|
2009-05-17 07:36:01 +02:00
|
|
|
Translatable::set_current_locale('en_US');
|
2009-01-16 05:14:34 +01:00
|
|
|
SiteTree::flush_and_destroy_cache();
|
|
|
|
$parentPage = $this->objFromFixture('Page', 'parent');
|
2009-03-18 17:13:40 +01:00
|
|
|
$children = $parentPage->AllChildrenIncludingDeleted();
|
2009-01-16 05:14:34 +01:00
|
|
|
$this->assertEquals(
|
|
|
|
$parentPage->AllChildrenIncludingDeleted()->column('ID'),
|
|
|
|
array(
|
2009-03-18 17:13:40 +01:00
|
|
|
$child2PageID,
|
|
|
|
$child3PageID,
|
|
|
|
$child1PageID // $child1Page was deleted from stage, so the original record doesn't have the ID set
|
2009-01-16 05:14:34 +01:00
|
|
|
),
|
|
|
|
"Showing AllChildrenIncludingDeleted() in default language doesnt show deleted children in other languages"
|
|
|
|
);
|
2009-10-05 12:33:36 +02:00
|
|
|
|
2009-01-16 05:14:34 +01:00
|
|
|
// on original parent in translation mode
|
2009-05-17 07:36:01 +02:00
|
|
|
Translatable::set_current_locale('de_DE');
|
2009-01-16 05:14:34 +01:00
|
|
|
SiteTree::flush_and_destroy_cache();
|
|
|
|
$parentPage = $this->objFromFixture('Page', 'parent');
|
|
|
|
$this->assertEquals(
|
2009-04-23 06:41:49 +02:00
|
|
|
$translatedParentPage->AllChildrenIncludingDeleted()->column('ID'),
|
2009-01-16 05:14:34 +01:00
|
|
|
array(
|
2009-03-18 17:13:40 +01:00
|
|
|
$child2PageTranslatedID,
|
|
|
|
$child1PageTranslatedID // $child1PageTranslated was deleted from stage, so the original record doesn't have the ID set
|
2009-01-16 05:14:34 +01:00
|
|
|
),
|
2009-04-23 06:41:49 +02:00
|
|
|
"Showing AllChildrenIncludingDeleted() in translation mode with parent page in translated language shows children in translated language"
|
2009-01-16 05:14:34 +01:00
|
|
|
);
|
|
|
|
|
2009-05-17 07:36:01 +02:00
|
|
|
Translatable::set_current_locale('de_DE');
|
2009-04-23 06:41:49 +02:00
|
|
|
SiteTree::flush_and_destroy_cache();
|
|
|
|
$parentPage = $this->objFromFixture('Page', 'parent');
|
|
|
|
$this->assertEquals(
|
|
|
|
$parentPage->AllChildrenIncludingDeleted()->column('ID'),
|
|
|
|
array(),
|
|
|
|
"Showing AllChildrenIncludingDeleted() in translation mode with parent page in translated language shows children in default language"
|
|
|
|
);
|
2009-01-16 05:14:34 +01:00
|
|
|
|
|
|
|
// reset language
|
2009-05-17 07:36:01 +02:00
|
|
|
Translatable::set_current_locale('en_US');
|
2009-01-16 05:14:34 +01:00
|
|
|
}
|
2009-10-05 12:33:36 +02:00
|
|
|
|
2009-10-11 02:07:22 +02:00
|
|
|
function testRootUrlDefaultsToTranslatedLink() {
|
2009-02-22 22:30:41 +01:00
|
|
|
$origPage = $this->objFromFixture('Page', 'homepage_en');
|
|
|
|
$origPage->publish('Stage', 'Live');
|
ENHANCEMENT Adjusted SearchForm, Debug, ErrorPage, SiteTree to using locales instead of lang codes
API CHANGE Changed Translatable datamodel to use locales ("en_US") instead of lang values ("en).
API CHANGE Changed Translatable::$default_lang to $default_locale, Translatable::$reading_lang to $reading_locale
API CHANGE Using "locale" instead of "lang" in Translatable::choose_site_lang() to auto-detect language from cookies or GET parameters
API CHANGE Deprecated Translatable::is_default_lang(), set_default_lang(), get_default_lang(), current_lang(), set_reading_lang(), get_reading_lang(), get_by_lang(), get_one_by_lang()
API CHANGE Removed Translatable::get_original() - with the new "translation groups" concept there no longer is an original for a translation
BUGFIX Updated MigrateTranslatableTask to new Locale based datamodel
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73468 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-03-20 09:47:06 +01:00
|
|
|
$translationDe = $origPage->createTranslation('de_DE');
|
2009-02-22 22:30:41 +01:00
|
|
|
$translationDe->URLSegment = 'heim';
|
|
|
|
$translationDe->write();
|
|
|
|
$translationDe->publish('Stage', 'Live');
|
|
|
|
|
2009-04-28 01:08:39 +02:00
|
|
|
// test with translatable
|
2009-05-17 07:36:01 +02:00
|
|
|
Translatable::set_current_locale('de_DE');
|
2009-02-22 22:30:41 +01:00
|
|
|
$this->assertEquals(
|
2009-10-11 02:07:17 +02:00
|
|
|
RootURLController::get_homepage_link(),
|
2009-02-22 22:30:41 +01:00
|
|
|
'heim',
|
|
|
|
'Homepage with different URLSegment in non-default language is found'
|
|
|
|
);
|
|
|
|
|
2009-04-01 18:35:32 +02:00
|
|
|
// @todo Fix add/remove extension
|
2009-02-22 22:30:41 +01:00
|
|
|
// test with translatable disabled
|
2009-04-01 18:35:32 +02:00
|
|
|
// Object::remove_extension('Page', 'Translatable');
|
|
|
|
// $_SERVER['HTTP_HOST'] = '/';
|
|
|
|
// $this->assertEquals(
|
|
|
|
// RootURLController::get_homepage_urlsegment(),
|
|
|
|
// 'home',
|
|
|
|
// 'Homepage is showing in default language if ?lang GET variable is left out'
|
|
|
|
// );
|
|
|
|
// Object::add_extension('Page', 'Translatable');
|
2009-02-22 22:30:41 +01:00
|
|
|
|
|
|
|
// setting back to default
|
2009-05-17 07:36:01 +02:00
|
|
|
Translatable::set_current_locale('en_US');
|
2009-02-22 22:30:41 +01:00
|
|
|
}
|
2009-04-27 07:57:11 +02:00
|
|
|
|
|
|
|
function testSiteTreeChangePageTypeInMaster() {
|
|
|
|
// create original
|
|
|
|
$origPage = new SiteTree();
|
|
|
|
$origPage->Locale = 'en_US';
|
|
|
|
$origPage->write();
|
|
|
|
$origPageID = $origPage->ID;
|
|
|
|
|
|
|
|
// create translation
|
|
|
|
$translatedPage = $origPage->createTranslation('de_DE');
|
|
|
|
$translatedPageID = $translatedPage->ID;
|
|
|
|
|
|
|
|
// change page type
|
2009-10-14 08:35:45 +02:00
|
|
|
$newPage = $origPage->newClassInstance('RedirectorPage');
|
|
|
|
$newPage->write();
|
2009-04-27 07:57:11 +02:00
|
|
|
|
|
|
|
// re-fetch original page with new instance
|
|
|
|
$origPageChanged = DataObject::get_by_id('RedirectorPage', $origPageID);
|
|
|
|
$this->assertEquals($origPageChanged->ClassName, 'RedirectorPage',
|
|
|
|
'A ClassName change to an original page doesnt change original classname'
|
|
|
|
);
|
|
|
|
|
|
|
|
// re-fetch the translation with new instance
|
2009-05-17 07:36:01 +02:00
|
|
|
Translatable::set_current_locale('de_DE');
|
2009-04-27 07:57:11 +02:00
|
|
|
$translatedPageChanged = DataObject::get_by_id('RedirectorPage', $translatedPageID);
|
|
|
|
$translatedPageChanged = $origPageChanged->getTranslation('de_DE');
|
|
|
|
$this->assertEquals($translatedPageChanged->ClassName, 'RedirectorPage',
|
|
|
|
'ClassName change on an original page also changes ClassName attribute of translation'
|
|
|
|
);
|
|
|
|
}
|
2009-04-30 01:18:17 +02:00
|
|
|
|
|
|
|
function testGetTranslationByStage() {
|
|
|
|
$publishedPage = new SiteTree();
|
|
|
|
$publishedPage->Locale = 'en_US';
|
|
|
|
$publishedPage->Title = 'Published';
|
|
|
|
$publishedPage->write();
|
|
|
|
$publishedPage->publish('Stage', 'Live');
|
|
|
|
$publishedPage->Title = 'Unpublished';
|
|
|
|
$publishedPage->write();
|
|
|
|
|
|
|
|
$publishedTranslatedPage = $publishedPage->createTranslation('de_DE');
|
|
|
|
$publishedTranslatedPage->Title = 'Publiziert';
|
|
|
|
$publishedTranslatedPage->write();
|
|
|
|
$publishedTranslatedPage->publish('Stage', 'Live');
|
|
|
|
$publishedTranslatedPage->Title = 'Unpubliziert';
|
|
|
|
$publishedTranslatedPage->write();
|
|
|
|
|
|
|
|
$compareStage = $publishedPage->getTranslation('de_DE', 'Stage');
|
|
|
|
$this->assertNotNull($compareStage);
|
|
|
|
$this->assertEquals($compareStage->Title, 'Unpubliziert');
|
|
|
|
|
|
|
|
$compareLive = $publishedPage->getTranslation('de_DE', 'Live');
|
|
|
|
$this->assertNotNull($compareLive);
|
|
|
|
$this->assertEquals($compareLive->Title, 'Publiziert');
|
|
|
|
}
|
2009-10-05 12:33:36 +02:00
|
|
|
|
|
|
|
function testCanTranslateAllowedLocales() {
|
2009-05-14 07:16:49 +02:00
|
|
|
$origAllowedLocales = Translatable::get_allowed_locales();
|
|
|
|
|
|
|
|
$cmseditor = $this->objFromFixture('Member', 'cmseditor');
|
|
|
|
|
|
|
|
$testPage = $this->objFromFixture('Page', 'testpage_en');
|
|
|
|
$this->assertTrue(
|
|
|
|
$testPage->canTranslate($cmseditor, 'de_DE'),
|
2009-10-05 12:33:36 +02:00
|
|
|
"Users with canEdit() and TRANSLATE_ALL permission can create a new translation if locales are not limited"
|
2009-05-14 07:16:49 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
Translatable::set_allowed_locales(array('ja_JP'));
|
|
|
|
$this->assertTrue(
|
|
|
|
$testPage->canTranslate($cmseditor, 'ja_JP'),
|
2009-10-05 12:33:36 +02:00
|
|
|
"Users with canEdit() and TRANSLATE_ALL permission can create a new translation if locale is in Translatable::get_allowed_locales()"
|
2009-05-14 07:16:49 +02:00
|
|
|
);
|
|
|
|
$this->assertFalse(
|
|
|
|
$testPage->canTranslate($cmseditor, 'de_DE'),
|
2009-10-05 12:33:36 +02:00
|
|
|
"Users with canEdit() and TRANSLATE_ALL permission can't create a new translation if locale is not in Translatable::get_allowed_locales()"
|
2009-05-14 07:16:49 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertType(
|
|
|
|
'Page',
|
|
|
|
$testPage->createTranslation('ja_JP')
|
|
|
|
);
|
|
|
|
try {
|
|
|
|
$testPage->createTranslation('de_DE');
|
|
|
|
$this->setExpectedException("Exception");
|
|
|
|
} catch(Exception $e) {}
|
|
|
|
|
|
|
|
Translatable::set_allowed_locales($origAllowedLocales);
|
|
|
|
}
|
2009-06-16 01:34:43 +02:00
|
|
|
|
2009-10-05 12:33:36 +02:00
|
|
|
function testCanTranslatePermissionCodes() {
|
|
|
|
$origAllowedLocales = Translatable::get_allowed_locales();
|
|
|
|
|
|
|
|
Translatable::set_allowed_locales(array('ja_JP','de_DE'));
|
|
|
|
|
|
|
|
$cmseditor = $this->objFromFixture('Member', 'cmseditor');
|
|
|
|
|
|
|
|
$testPage = $this->objFromFixture('Page', 'testpage_en');
|
|
|
|
$this->assertTrue(
|
|
|
|
$testPage->canTranslate($cmseditor, 'de_DE'),
|
|
|
|
"Users with TRANSLATE_ALL permission can create a new translation"
|
|
|
|
);
|
|
|
|
|
|
|
|
$translator = $this->objFromFixture('Member', 'germantranslator');
|
|
|
|
|
|
|
|
$testPage = $this->objFromFixture('Page', 'testpage_en');
|
|
|
|
$this->assertTrue(
|
|
|
|
$testPage->canTranslate($translator, 'de_DE'),
|
|
|
|
"Users with TRANSLATE_<locale> permission can create a new translation"
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertFalse(
|
|
|
|
$testPage->canTranslate($translator, 'ja_JP'),
|
|
|
|
"Users without TRANSLATE_<locale> permission can create a new translation"
|
|
|
|
);
|
|
|
|
|
|
|
|
Translatable::set_allowed_locales($origAllowedLocales);
|
|
|
|
}
|
|
|
|
|
2009-10-05 22:07:03 +02:00
|
|
|
function testLocalesForMember() {
|
|
|
|
$origAllowedLocales = Translatable::get_allowed_locales();
|
|
|
|
Translatable::set_allowed_locales(array('de_DE', 'ja_JP'));
|
|
|
|
|
|
|
|
$cmseditor = $this->objFromFixture('Member', 'cmseditor');
|
|
|
|
$translator = $this->objFromFixture('Member', 'germantranslator');
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
array('de_DE', 'ja_JP'),
|
|
|
|
singleton('SiteTree')->getAllowedLocalesForMember($cmseditor),
|
|
|
|
'Members with TRANSLATE_ALL permission can edit all locales'
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
array('de_DE'),
|
|
|
|
singleton('SiteTree')->getAllowedLocalesForMember($translator),
|
|
|
|
'Members with TRANSLATE_<locale> permission cant edit all locales'
|
|
|
|
);
|
|
|
|
|
|
|
|
Translatable::set_allowed_locales($origAllowedLocales);
|
|
|
|
}
|
|
|
|
|
2009-06-16 01:34:43 +02:00
|
|
|
function testSavePageInCMS() {
|
2009-06-16 01:49:17 +02:00
|
|
|
$adminUser = $this->objFromFixture('Member', 'admin');
|
2009-06-16 01:34:43 +02:00
|
|
|
$enPage = $this->objFromFixture('Page', 'testpage_en');
|
|
|
|
|
|
|
|
$group = new Group();
|
|
|
|
$group->Title = 'Example Group';
|
|
|
|
$group->write();
|
|
|
|
|
|
|
|
$frPage = $enPage->createTranslation('fr_FR');
|
|
|
|
$frPage->write();
|
|
|
|
|
2009-06-16 01:49:17 +02:00
|
|
|
$adminUser->logIn();
|
|
|
|
|
2009-06-16 01:34:43 +02:00
|
|
|
$cmsMain = new CMSMain();
|
|
|
|
|
|
|
|
$origLocale = Translatable::get_current_locale();
|
|
|
|
Translatable::set_current_locale('fr_FR');
|
|
|
|
|
|
|
|
$form = $cmsMain->getEditForm($frPage->ID);
|
|
|
|
$form->loadDataFrom(array(
|
|
|
|
'Title' => 'Translated', // $db field
|
|
|
|
'ViewerGroups' => $group->ID // $many_many field
|
|
|
|
));
|
|
|
|
$form->saveInto($frPage);
|
|
|
|
$frPage->write();
|
|
|
|
|
|
|
|
$this->assertEquals('Translated', $frPage->Title);
|
|
|
|
$this->assertEquals(array($group->ID), $frPage->ViewerGroups()->column('ID'));
|
|
|
|
|
2009-06-16 01:49:17 +02:00
|
|
|
$adminUser->logOut();
|
2009-06-16 01:34:43 +02:00
|
|
|
Translatable::set_current_locale($origLocale);
|
|
|
|
}
|
2009-08-18 00:46:39 +02:00
|
|
|
|
2009-10-11 02:07:22 +02:00
|
|
|
public function testAlternateGetByLink() {
|
|
|
|
$parent = $this->objFromFixture('Page', 'parent');
|
|
|
|
$child = $this->objFromFixture('Page', 'child1');
|
|
|
|
$grandchild = $this->objFromFixture('Page', 'grandchild1');
|
|
|
|
|
|
|
|
$parentTranslation = $parent->createTranslation('en_AU');
|
|
|
|
$parentTranslation->write();
|
|
|
|
|
|
|
|
$childTranslation = $child->createTranslation('en_AU');
|
|
|
|
$childTranslation->write();
|
|
|
|
|
|
|
|
$grandchildTranslation = $grandchild->createTranslation('en_AU');
|
|
|
|
$grandchildTranslation->write();
|
|
|
|
|
|
|
|
SiteTree::enable_nested_urls();
|
|
|
|
Translatable::set_current_locale('en_AU');
|
|
|
|
|
|
|
|
$this->assertEquals (
|
|
|
|
$parentTranslation->ID,
|
|
|
|
Sitetree::get_by_link($parentTranslation->Link())->ID,
|
|
|
|
'Top level pages can be found.'
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals (
|
|
|
|
$childTranslation->ID,
|
|
|
|
SiteTree::get_by_link($childTranslation->Link())->ID,
|
|
|
|
'Child pages can be found.'
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals (
|
|
|
|
$grandchildTranslation->ID,
|
|
|
|
SiteTree::get_by_link($grandchildTranslation->Link())->ID,
|
|
|
|
'Grandchild pages can be found.'
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals (
|
|
|
|
$childTranslation->ID,
|
|
|
|
SiteTree::get_by_link($parentTranslation->Link($child->URLSegment))->ID,
|
|
|
|
'Links can be made up of multiple languages'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSiteTreeGetByLinkFindsTranslationWithoutLocale() {
|
2009-08-18 00:46:39 +02:00
|
|
|
$parent = $this->objFromFixture('Page', 'parent');
|
|
|
|
|
|
|
|
$parentTranslation = $parent->createTranslation('en_AU');
|
|
|
|
$parentTranslation->URLSegment = 'parent-en-AU';
|
|
|
|
$parentTranslation->write();
|
|
|
|
|
2009-10-11 02:07:22 +02:00
|
|
|
$match = Sitetree::get_by_link($parentTranslation->URLSegment);
|
2009-08-18 00:46:39 +02:00
|
|
|
$this->assertNotNull(
|
|
|
|
$match,
|
2009-10-11 02:07:22 +02:00
|
|
|
'SiteTree::get_by_link() doesnt need a locale setting to find translated pages'
|
2009-08-18 00:46:39 +02:00
|
|
|
);
|
|
|
|
$this->assertEquals(
|
|
|
|
$parentTranslation->ID,
|
|
|
|
$match->ID,
|
2009-10-11 02:07:22 +02:00
|
|
|
'SiteTree::get_by_link() doesnt need a locale setting to find translated pages'
|
2009-08-18 00:46:39 +02:00
|
|
|
);
|
|
|
|
}
|
2009-01-10 13:38:50 +01:00
|
|
|
}
|
2009-01-13 23:28:24 +01:00
|
|
|
|
2009-01-14 05:10:54 +01:00
|
|
|
class TranslatableTest_DataObject extends DataObject implements TestOnly {
|
2009-04-01 18:35:32 +02:00
|
|
|
// add_extension() used to add decorator at end of file
|
2009-01-13 23:28:24 +01:00
|
|
|
|
|
|
|
static $db = array(
|
|
|
|
'TranslatableProperty' => 'Text'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2009-01-14 05:10:54 +01:00
|
|
|
class TranslatableTest_Decorator extends DataObjectDecorator implements TestOnly {
|
2009-01-13 23:28:24 +01:00
|
|
|
|
|
|
|
function extraStatics() {
|
|
|
|
return array(
|
|
|
|
'db' => array(
|
|
|
|
'TranslatableDecoratedProperty' => 'Text'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-18 23:48:45 +01:00
|
|
|
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'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2009-01-14 05:10:54 +01:00
|
|
|
DataObject::add_extension('TranslatableTest_DataObject', 'TranslatableTest_Decorator');
|
2009-10-11 02:07:17 +02:00
|
|
|
?>
|