diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2016-11-02 01:19:16 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2016-11-02 01:19:16 +0300 |
commit | f1ddc5c2fccf0c67a1cc8cc56052594b9e35e6af (patch) | |
tree | 901dd0f1762bf604fe97aa67652b2ba02a01e301 /tests/HordeTranslationHandlerTest.php | |
parent | 304ddca8a1382b41017f54cc1f52533a6f0e0a55 (diff) |
fix tests
* use PSR-4
* consistently use phpunit's testcase as base class
* small doc block fixes
Diffstat (limited to 'tests/HordeTranslationHandlerTest.php')
-rw-r--r-- | tests/HordeTranslationHandlerTest.php | 66 |
1 files changed, 66 insertions, 0 deletions
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 @@ +<?php + +/** + * @author Christoph Wurst <christoph@winzerhof-wurst.at> + * + * 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 <http://www.gnu.org/licenses/> + * + */ +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); + } + +} |