From a22aa4ab05e50bb0bdd5e59a27b5f1867323f7a2 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 21 Dec 2009 11:29:28 -0800 Subject: Forgot to rename the file when I renamed the class. --- modules/gallery/tests/Gallery_I18n_Test.php | 108 ++++++++++++++++++++++++++++ modules/gallery/tests/I18n_Test.php | 108 ---------------------------- 2 files changed, 108 insertions(+), 108 deletions(-) create mode 100644 modules/gallery/tests/Gallery_I18n_Test.php delete mode 100644 modules/gallery/tests/I18n_Test.php (limited to 'modules') diff --git a/modules/gallery/tests/Gallery_I18n_Test.php b/modules/gallery/tests/Gallery_I18n_Test.php new file mode 100644 index 00000000..895e3051 --- /dev/null +++ b/modules/gallery/tests/Gallery_I18n_Test.php @@ -0,0 +1,108 @@ + 'en', + 'default_locale' => 'te_ST', + 'locale_dir' => VARPATH . 'locale/'); + $this->i18n = Gallery_I18n::instance($config); + + ORM::factory("incoming_translation") + ->where("locale", "=", "te_ST") + ->delete_all(); + + $messages_te_ST = array( + array('Hello world', 'Hallo Welt'), + array(array('one' => 'One item has been added', + 'other' => '%count elements have been added'), + array('one' => 'Ein Element wurde hinzugefuegt.', + 'other' => '%count Elemente wurden hinzugefuegt.')), + array('Hello %name, how are you today?', 'Hallo %name, wie geht es Dir heute?')); + + foreach ($messages_te_ST as $data) { + list ($message, $translation) = $data; + $entry = ORM::factory("incoming_translation"); + $entry->key = Gallery_I18n::get_message_key($message); + $entry->message = serialize($message); + $entry->translation = serialize($translation); + $entry->locale = 'te_ST'; + $entry->revision = null; + $entry->save(); + } + } + + public function get_locale_test() { + $locale = $this->i18n->locale(); + $this->assert_equal("te_ST", $locale); + } + + public function set_locale_test() { + $this->i18n->locale("de_DE"); + $locale = $this->i18n->locale(); + $this->assert_equal("de_DE", $locale); + } + + public function translate_simple_test() { + $result = $this->i18n->translate('Hello world'); + $this->assert_equal('Hallo Welt', $result); + } + + public function translate_simple_root_fallback_test() { + $result = $this->i18n->translate('Hello world zzz'); + $this->assert_equal('Hello world zzz', $result); + } + + public function translate_plural_other_test() { + $result = $this->i18n->translate(array('one' => 'One item has been added', + 'other' => '%count elements have been added'), + array('count' => 5)); + $this->assert_equal('5 Elemente wurden hinzugefuegt.', $result); + } + + public function translate_plural_one_test() { + $result = $this->i18n->translate(array('one' => 'One item has been added', + 'other' => '%count elements have been added'), + array('count' => 1)); + $this->assert_equal('Ein Element wurde hinzugefuegt.', $result); + } + + public function translate_interpolate_test() { + $result = $this->i18n->translate('Hello %name, how are you today?', array('name' => 'John')); + $this->assert_equal('Hallo John, wie geht es Dir heute?', $result); + } + + public function translate_interpolate_missing_value_test() { + $result = $this->i18n->translate('Hello %name, how are you today?', array('foo' => 'bar')); + $this->assert_equal('Hallo %name, wie geht es Dir heute?', $result); + } + + public function translate_plural_zero_test() { + // te_ST has the same plural rules as en and de. + // For count 0, plural form "other" should be used. + $result = $this->i18n->translate(array('one' => 'One item has been added', + 'other' => '%count elements have been added'), + array('count' => 0)); + $this->assert_equal('0 Elemente wurden hinzugefuegt.', $result); + } +} \ No newline at end of file diff --git a/modules/gallery/tests/I18n_Test.php b/modules/gallery/tests/I18n_Test.php deleted file mode 100644 index 895e3051..00000000 --- a/modules/gallery/tests/I18n_Test.php +++ /dev/null @@ -1,108 +0,0 @@ - 'en', - 'default_locale' => 'te_ST', - 'locale_dir' => VARPATH . 'locale/'); - $this->i18n = Gallery_I18n::instance($config); - - ORM::factory("incoming_translation") - ->where("locale", "=", "te_ST") - ->delete_all(); - - $messages_te_ST = array( - array('Hello world', 'Hallo Welt'), - array(array('one' => 'One item has been added', - 'other' => '%count elements have been added'), - array('one' => 'Ein Element wurde hinzugefuegt.', - 'other' => '%count Elemente wurden hinzugefuegt.')), - array('Hello %name, how are you today?', 'Hallo %name, wie geht es Dir heute?')); - - foreach ($messages_te_ST as $data) { - list ($message, $translation) = $data; - $entry = ORM::factory("incoming_translation"); - $entry->key = Gallery_I18n::get_message_key($message); - $entry->message = serialize($message); - $entry->translation = serialize($translation); - $entry->locale = 'te_ST'; - $entry->revision = null; - $entry->save(); - } - } - - public function get_locale_test() { - $locale = $this->i18n->locale(); - $this->assert_equal("te_ST", $locale); - } - - public function set_locale_test() { - $this->i18n->locale("de_DE"); - $locale = $this->i18n->locale(); - $this->assert_equal("de_DE", $locale); - } - - public function translate_simple_test() { - $result = $this->i18n->translate('Hello world'); - $this->assert_equal('Hallo Welt', $result); - } - - public function translate_simple_root_fallback_test() { - $result = $this->i18n->translate('Hello world zzz'); - $this->assert_equal('Hello world zzz', $result); - } - - public function translate_plural_other_test() { - $result = $this->i18n->translate(array('one' => 'One item has been added', - 'other' => '%count elements have been added'), - array('count' => 5)); - $this->assert_equal('5 Elemente wurden hinzugefuegt.', $result); - } - - public function translate_plural_one_test() { - $result = $this->i18n->translate(array('one' => 'One item has been added', - 'other' => '%count elements have been added'), - array('count' => 1)); - $this->assert_equal('Ein Element wurde hinzugefuegt.', $result); - } - - public function translate_interpolate_test() { - $result = $this->i18n->translate('Hello %name, how are you today?', array('name' => 'John')); - $this->assert_equal('Hallo John, wie geht es Dir heute?', $result); - } - - public function translate_interpolate_missing_value_test() { - $result = $this->i18n->translate('Hello %name, how are you today?', array('foo' => 'bar')); - $this->assert_equal('Hallo %name, wie geht es Dir heute?', $result); - } - - public function translate_plural_zero_test() { - // te_ST has the same plural rules as en and de. - // For count 0, plural form "other" should be used. - $result = $this->i18n->translate(array('one' => 'One item has been added', - 'other' => '%count elements have been added'), - array('count' => 0)); - $this->assert_equal('0 Elemente wurden hinzugefuegt.', $result); - } -} \ No newline at end of file -- cgit v1.2.3