Skip to content

Commit

Permalink
Extend TranslatorTest with new tests
Browse files Browse the repository at this point in the history
refs #6982
  • Loading branch information
Alexander Fuhr committed Sep 16, 2014
1 parent b38ef9c commit 0be8b97
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 1 deletion.
72 changes: 72 additions & 0 deletions test/php/library/Icinga/Util/TranslatorTest.php
Expand Up @@ -213,4 +213,76 @@ public function testWhetherGetPreferredLocaleCodeReturnsTheDefaultLocaleIfNoMatc
'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'
);
}
}
Binary file modified test/php/res/locale/de_DE/LC_MESSAGES/icingatest.mo
Binary file not shown.
42 changes: 41 additions & 1 deletion 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 <alexander.fuhr@netways.de>\n"
"Language: de_DE\n"
"Language-Team: LANGUAGE <LL@li.org>\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!"
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"

0 comments on commit 0be8b97

Please sign in to comment.