From f1ddc5c2fccf0c67a1cc8cc56052594b9e35e6af Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Tue, 1 Nov 2016 23:19:16 +0100 Subject: fix tests * use PSR-4 * consistently use phpunit's testcase as base class * small doc block fixes --- tests/HordeTranslationHandlerTest.php | 66 +++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 tests/HordeTranslationHandlerTest.php (limited to 'tests/HordeTranslationHandlerTest.php') diff --git a/tests/HordeTranslationHandlerTest.php b/tests/HordeTranslationHandlerTest.php new file mode 100644 index 000000000..c0c9a246b --- /dev/null +++ b/tests/HordeTranslationHandlerTest.php @@ -0,0 +1,66 @@ + + * + * Mail + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see + * + */ +namespace OCA\Mail\Tests; + +use PHPUnit_Framework_TestCase; +use OCA\Mail\HordeTranslationHandler; + +class HordeTranslationHandlerTest extends PHPUnit_Framework_TestCase { + + private $handler; + + protected function setUp() { + parent::setUp(); + + $this->handler = new HordeTranslationHandler(); + } + + public function testT() { + $message = 'Hello'; + + $expected = $message; + $actual = $this->handler->t($message); + + $this->assertEquals($expected, $actual); + } + + public function singularPluralDataProvider() { + return [ + [0], + [1], + [2], + ]; + } + + /** + * @dataProvider singularPluralDataProvider + */ + public function testNgettext($number) { + $singular = 'mail'; + $plural = 'mails'; + + $expected = $number > 1 ? $plural : $singular; + $actual = $this->handler->ngettext($singular, $plural, $number); + + $this->assertEquals($expected, $actual); + } + +} -- cgit v1.2.3