From c3d8d82d52006a20c628c5dd8ae27d3f73df5d86 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 29 May 2012 13:54:49 +0200 Subject: [PATCH] MINOR Testing languages without fallbacks (related to #7386) --- .../i18ntestmodule/lang/mi_NZ.yml | 3 +++ tests/i18n/i18nTest.php | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tests/i18n/_fakewebroot/i18ntestmodule/lang/mi_NZ.yml diff --git a/tests/i18n/_fakewebroot/i18ntestmodule/lang/mi_NZ.yml b/tests/i18n/_fakewebroot/i18ntestmodule/lang/mi_NZ.yml new file mode 100644 index 000000000..c3ca35a0e --- /dev/null +++ b/tests/i18n/_fakewebroot/i18ntestmodule/lang/mi_NZ.yml @@ -0,0 +1,3 @@ +mi_NZ: + i18nTestModule: + ENTITY: Translation (mi_NZ) \ No newline at end of file diff --git a/tests/i18n/i18nTest.php b/tests/i18n/i18nTest.php index 6f69a0360..766272313 100644 --- a/tests/i18n/i18nTest.php +++ b/tests/i18n/i18nTest.php @@ -431,6 +431,30 @@ class i18nTest extends SapphireTest { SS_ClassLoader::instance()->popManifest(); } + + function testIncludeByLocaleWithoutFallbackLanguage() { + $classManifest = new SS_ClassManifest($this->alternateBasePath, true, true, false); + SS_ClassLoader::instance()->pushManifest($classManifest); + + $adapter = i18n::get_translator('core')->getAdapter(); + $this->assertTrue($adapter->isAvailable('en')); + $this->assertFalse($adapter->isAvailable('mi')); // not defined at all + $this->assertFalse($adapter->isAvailable('mi_NZ')); // defined, but not loaded yet + $this->assertFalse($adapter->isTranslated('i18nTestModule.ENTITY', 'mi'), + 'Existing unloaded entity not available before call' + ); + $this->assertFalse($adapter->isTranslated('i18nTestModule.ENTITY', 'mi_NZ'), + 'Non-existing unloaded entity not available before call' + ); + + i18n::include_by_locale('mi_NZ'); + + $this->assertFalse($adapter->isAvailable('mi')); + $this->assertTrue($adapter->isAvailable('mi_NZ')); + $this->assertTrue($adapter->isTranslated('i18nTestModule.ENTITY', null, 'mi_NZ'), 'Includes module files'); + + SS_ClassLoader::instance()->popManifest(); + } function testRegisterTranslator() { $translator = new Zend_Translate(array(