From 0be71a08d6aeed2074d5e68f3e9cd029d944a540 Mon Sep 17 00:00:00 2001 From: ADmad Date: Tue, 10 Jan 2012 01:19:26 +0530 Subject: [PATCH] Adding / updating I18n class test cases. --- lib/Cake/Test/Case/I18n/I18nTest.php | 54 +++++++++++++++++++++------- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/lib/Cake/Test/Case/I18n/I18nTest.php b/lib/Cake/Test/Case/I18n/I18nTest.php index 25226bb26ad..307cf0d7f73 100644 --- a/lib/Cake/Test/Case/I18n/I18nTest.php +++ b/lib/Cake/Test/Case/I18n/I18nTest.php @@ -50,10 +50,14 @@ public function tearDown() { CakePlugin::unload(); } - +/** + * testTranslationCaching method + * + * @return void + */ public function testTranslationCaching() { Configure::write('Config.language', 'cache_test_po'); - $i18n = i18n::getInstance(); + $i18n = I18n::getInstance(); // reset internally stored entries I18n::clear(); @@ -93,7 +97,6 @@ public function testTranslationCaching() { $this->assertEquals('FOO', I18n::translate('dom1.foo', false, 'dom1')); } - /** * testDefaultStrings method * @@ -2588,6 +2591,11 @@ public function testCategoryThenSingular() { $this->assertEquals('Po (translated)', $singular); } +/** + * testTimeDefinition method + * + * @return void + */ public function testTimeDefinition() { Configure::write('Config.language', 'po'); $result = __c('d_fmt', 5); @@ -2603,6 +2611,11 @@ public function testTimeDefinition() { $this->assertEquals($expected, $result); } +/** + * testTimeDefinitionJapanese method + * + * @return void + */ public function testTimeDefinitionJapanese() { Configure::write('Config.language', 'ja_jp'); $result = __c('d_fmt', 5); @@ -2620,12 +2633,29 @@ public function testTimeDefinitionJapanese() { $this->assertEquals($expected, $result); } +/** + * testTranslateLanguageParam method + * + * @return void + */ + public function testTranslateLanguageParam() { + Configure::write('Config.language', 'rule_0_po'); + + $result = I18n::translate('Plural Rule 1', null, null, 6); + $expected = 'Plural Rule 0 (translated)'; + $this->assertEquals($expected, $result); + + $result = I18n::translate('Plural Rule 1', null, null, 6, null, 'rule_1_po'); + $expected = 'Plural Rule 1 (translated)'; + $this->assertEquals($expected, $result); + } + /** * Singular method * * @return void */ - function __domainCategorySingular($domain = 'test_plugin', $category = 3) { + private function __domainCategorySingular($domain = 'test_plugin', $category = 3) { $singular = __dc($domain, 'Plural Rule 1', $category); return $singular; } @@ -2635,7 +2665,7 @@ function __domainCategorySingular($domain = 'test_plugin', $category = 3) { * * @return void */ - function __domainCategoryPlural($domain = 'test_plugin', $category = 3) { + private function __domainCategoryPlural($domain = 'test_plugin', $category = 3) { $plurals = array(); for ($number = 0; $number <= 25; $number++) { $plurals[] = sprintf(__dcn($domain, '%d = 1', '%d = 0 or > 1', (float)$number, $category), (float)$number); @@ -2648,7 +2678,7 @@ function __domainCategoryPlural($domain = 'test_plugin', $category = 3) { * * @return void */ - function __domainSingular($domain = 'test_plugin') { + private function __domainSingular($domain = 'test_plugin') { $singular = __d($domain, 'Plural Rule 1'); return $singular; } @@ -2658,7 +2688,7 @@ function __domainSingular($domain = 'test_plugin') { * * @return void */ - function __domainPlural($domain = 'test_plugin') { + private function __domainPlural($domain = 'test_plugin') { $plurals = array(); for ($number = 0; $number <= 25; $number++) { $plurals[] = sprintf(__dn($domain, '%d = 1', '%d = 0 or > 1', (float)$number), (float)$number ); @@ -2671,7 +2701,7 @@ function __domainPlural($domain = 'test_plugin') { * * @return void */ - function __category($category = 3) { + private function __category($category = 3) { $singular = __c('Plural Rule 1', $category); return $singular; } @@ -2681,7 +2711,7 @@ function __category($category = 3) { * * @return void */ - function __singular() { + private function __singular() { $singular = __('Plural Rule 1'); return $singular; } @@ -2691,7 +2721,7 @@ function __singular() { * * @return void */ - function __plural() { + private function __plural() { $plurals = array(); for ($number = 0; $number <= 25; $number++) { $plurals[] = sprintf(__n('%d = 1', '%d = 0 or > 1', (float)$number), (float)$number); @@ -2704,7 +2734,7 @@ function __plural() { * * @return void */ - function __singularFromCore() { + private function __singularFromCore() { $singular = __('Plural Rule 1 (from core)'); return $singular; } @@ -2714,7 +2744,7 @@ function __singularFromCore() { * * @return void */ - function __pluralFromCore() { + private function __pluralFromCore() { $plurals = array(); for ($number = 0; $number <= 25; $number++) { $plurals[] = sprintf(__n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', (float)$number), (float)$number );