From 0be8b97e88e0a79f3013576867dc997a52e1f6be Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Tue, 16 Sep 2014 16:14:07 +0200 Subject: [PATCH] Extend TranslatorTest with new tests refs #6982 --- .../library/Icinga/Util/TranslatorTest.php | 72 ++++++++++++++++++ .../locale/de_DE/LC_MESSAGES/icingatest.mo | Bin 111 -> 997 bytes .../locale/de_DE/LC_MESSAGES/icingatest.po | 42 +++++++++- 3 files changed, 113 insertions(+), 1 deletion(-) diff --git a/test/php/library/Icinga/Util/TranslatorTest.php b/test/php/library/Icinga/Util/TranslatorTest.php index 9e341d545..4d74cc8dc 100644 --- a/test/php/library/Icinga/Util/TranslatorTest.php +++ b/test/php/library/Icinga/Util/TranslatorTest.php @@ -213,4 +213,76 @@ class TranslatorTest extends BaseTestCase 'Translator::getPreferredLocaleCode does not return the default locale if no match could be found' ); } + + /** + * @depends testWhetherSetupLocaleSetsUpTheGivenLocale + */ + public function testWhetherTranslatePluralReturnsTheSingularForm() + { + Translator::setupLocale('de_DE'); + + $result = Translator::translatePlural('test service', 'test services', 1, 'icingatest'); + + $expected = 'test dienst'; + + $this->assertEquals( + $expected, + $result, + 'Translator::translatePlural() could not return the translated singular form' + ); + } + + /** + * @depends testWhetherSetupLocaleSetsUpTheGivenLocale + */ + public function testWhetherTranslatePluralReturnsThePluralForm() + { + Translator::setupLocale('de_DE'); + + $result = Translator::translatePlural('test service', 'test services', 2, 'icingatest'); + + $expected = 'test dienste'; + + $this->assertEquals( + $expected, + $result, + 'Translator::translatePlural() could not return the translated plural form' + ); + } + + /** + * @depends testWhetherSetupLocaleSetsUpTheGivenLocale + */ + public function testWhetherTranslateReturnsTheContextForm() + { + Translator::setupLocale('de_DE'); + + $result = Translator::translate('context service', 'icingatest', 'test2'); + + $expected = 'context dienst test2'; + + $this->assertEquals( + $expected, + $result, + 'Translator::translate() could not return the translated context form' + ); + } + + /** + * @depends testWhetherSetupLocaleSetsUpTheGivenLocale + */ + public function testWhetherTranslatePluralReturnsTheContextForm() + { + Translator::setupLocale('de_DE'); + + $result = Translator::translatePlural('context service', 'context services', 3, 'icingatest', 'test-context'); + + $expected = 'context plural dienste'; + + $this->assertEquals( + $expected, + $result, + 'Translator::translatePlural() could not return the translated context form' + ); + } } diff --git a/test/php/res/locale/de_DE/LC_MESSAGES/icingatest.mo b/test/php/res/locale/de_DE/LC_MESSAGES/icingatest.mo index 487e490237f1702eefb05f227d70d93ed0d484ca..621eab2bf8652f46a1c76a642e0c32d22fbc6144 100644 GIT binary patch literal 997 zcma)4&2AGh5MCgFwA}cS5OA2@S_Ln=OIxLzrb=j&C{hAZwFM*&$laZ$MjJb_y=nUn zTzLSVfeX9^2hQAi3ug1%(pF-mPoHP}&3J6j@B5`M4%uD8GeS(bNBB%A>^tEJ;RoR% z;n&RnL(B-J8;;`i#6A6o+VG zw`p~gQ1o_(P$Dd>t27Qlj7&a+RAowo5f=Cmtz*&HQlg~AQws+5SR^<6Ula${MnxilHKN=MMh@RZ9GHMH_$4cmO~dq?EgCE62yX1o-4C|3@0 zKA;{_{J7U#_$)>~jG)_i-9Bivo3P#O)-zG`zvK2gz2@>Y0?&7Mi$9dq#My`{72o+{ zlyM=ekQ{Su(AEy(7OO0EMYBh!SyLt|rPqw0awx3Z&vMN()>3+CB9NnrYieN?rpwx@ zgq0cuYgP9>YokOxy>MS)N<$TR8{WF>Tt9Iu&U{Kzfs#J1n84}8O#|oGxDZbdhnZwv T;zINqaej3TT*l8e5;}hYw_YQW literal 111 zcmca7#4?ou2pEA_28dOFm>Gz5fLIEMEr3`Wh=YL`1VHLQz$d>bHCG|Cptv+wAtgU2 Tzeu4tvqT{=H?;(hlp+HFK^+!k diff --git a/test/php/res/locale/de_DE/LC_MESSAGES/icingatest.po b/test/php/res/locale/de_DE/LC_MESSAGES/icingatest.po index 2bf77ccae..3215ac4f7 100644 --- a/test/php/res/locale/de_DE/LC_MESSAGES/icingatest.po +++ b/test/php/res/locale/de_DE/LC_MESSAGES/icingatest.po @@ -1,2 +1,42 @@ +msgid "" +msgstr "" +"Project-Id-Version: Icinga Web 2 Test (0.0.1)\n" +"Report-Msgid-Bugs-To: dev@icinga.org\n" +"POT-Creation-Date: 2014-09-16 13:29+0200\n" +"PO-Revision-Date: 2014-09-16 16:08+0100\n" +"Last-Translator: Alexander Fuhr \n" +"Language: de_DE\n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 1.5.4\n" + msgid "Lorem ipsum dolor sit amet" -msgstr "Lorem ipsum dolor sit amet!" \ No newline at end of file +msgstr "Lorem ipsum dolor sit amet!" + +msgid "test service" +msgid_plural "test services" +msgstr[0] "test dienst" +msgstr[1] "test dienste" + +msgctxt "test" +msgid "context service" +msgstr "context dienst test" + +msgctxt "test2" +msgid "context service" +msgstr "context dienst test2" + +msgctxt "test-contextu" +msgid "context service" +msgid_plural "context services" +msgstr[0] "context plural dienstu" +msgstr[1] "context plural diensteu" + +msgctxt "test-context" +msgid "context service" +msgid_plural "context services" +msgstr[0] "context plural dienst" +msgstr[1] "context plural dienste"