From: Jan Schneider Date: Tue, 12 Oct 2010 22:16:20 +0000 (+0200) Subject: Add unit test. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=bc6dd5ffcf5402c9ea40296df830902c963e2a10;p=horde.git Add unit test. --- diff --git a/framework/Translation/test/Horde/Translation/AllTests.php b/framework/Translation/test/Horde/Translation/AllTests.php new file mode 100644 index 000000000..22e60a80b --- /dev/null +++ b/framework/Translation/test/Horde/Translation/AllTests.php @@ -0,0 +1,36 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @category Horde + * @package Translation + * @subpackage UnitTests + */ + +/** + * Define the main method + */ +if (!defined('PHPUnit_MAIN_METHOD')) { + define('PHPUnit_MAIN_METHOD', 'Horde_Translation_AllTests::main'); +} + +/** + * Prepare the test setup. + */ +require_once 'Horde/Test/AllTests.php'; + +/** + * @package Horde_Translation + * @subpackage UnitTests + */ +class Horde_Translation_AllTests extends Horde_Test_AllTests +{ +} + +Horde_Translation_AllTests::init('Horde_Translation', __FILE__); + +if (PHPUnit_MAIN_METHOD == 'Horde_Translation_AllTests::main') { + Horde_Translation_AllTests::main(); +} diff --git a/framework/Translation/test/Horde/Translation/GettextTest.php b/framework/Translation/test/Horde/Translation/GettextTest.php new file mode 100644 index 000000000..7d8cd4d3f --- /dev/null +++ b/framework/Translation/test/Horde/Translation/GettextTest.php @@ -0,0 +1,34 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @category Horde + * @package Translation + * @subpackage UnitTests + */ + +class Horde_Translation_GettextTest extends PHPUnit_Framework_TestCase +{ + private $_dict; + + public function setUp() + { + putenv('LC_ALL=de_DE.UTF-8'); + putenv('LANG=de_DE.UTF-8'); + putenv('LANGUAGE=de_DE.UTF-8'); + $this->_dict = new Horde_Translation_Gettext('Horde_Translation', dirname(__FILE__) . '/locale'); + } + + public function testGettext() + { + $this->assertEquals('Heute', $this->_dict->t('Today')); + $this->assertEquals('Schön', $this->_dict->t('Beautiful')); + $this->assertEquals('2 Tage', sprintf($this->_dict->t('%d days'), 2)); + } + + public function testNgettext() + { + $this->assertEquals('1 Woche', sprintf($this->_dict->ngettext('%d week', '%d weeks', 1), 1)); + $this->assertEquals('2 Wochen', sprintf($this->_dict->ngettext('%d week', '%d weeks', 2), 2)); + } +} diff --git a/framework/Translation/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Translation.mo b/framework/Translation/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Translation.mo new file mode 100644 index 000000000..19b919acc Binary files /dev/null and b/framework/Translation/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Translation.mo differ diff --git a/framework/Translation/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Translation.po b/framework/Translation/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Translation.po new file mode 100644 index 000000000..6221e5f4c --- /dev/null +++ b/framework/Translation/test/Horde/Translation/locale/de/LC_MESSAGES/Horde_Translation.po @@ -0,0 +1,31 @@ +# German test translation for Horde_Translation. +# Copyright 2010 The Horde Project (http://www.horde.org/) +# Jan Schneider , 2010. +msgid "" +msgstr "" +"Project-Id-Version: Horde_Translation\n" +"Report-Msgid-Bugs-To: dev@lists.horde.org\n" +"POT-Creation-Date: 2010-08-17 18:32+0200\n" +"PO-Revision-Date: 2010-08-25 13:24+0200\n" +"Last-Translator: Jan Schneider \n" +"Language-Team: German \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8-bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +msgid "Today" +msgstr "Heute" + +msgid "Beautiful" +msgstr "Schön" + +#, php-format +msgid "%d days" +msgstr "%d Tage" + +#, php-format +msgid "%d week" +msgid_plural "%d weeks" +msgstr[0] "%d Woche" +msgstr[1] "%d Wochen"