Completed
Pull Request — master (#1638)
by Thomas
06:26
created

HordeTranslationHandlerTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 5
c 1
b 1
f 0
lcom 1
cbo 1
dl 0
loc 41
rs 10
1
<?php
2
3
/**
4
 * @author Christoph Wurst <[email protected]>
5
 *
6
 * Mail
7
 *
8
 * This code is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Affero General Public License, version 3,
10
 * as published by the Free Software Foundation.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 * GNU Affero General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Affero General Public License, version 3,
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
19
 *
20
 */
21
namespace OCA\Mail\Tests;
22
23
use PHPUnit_Framework_TestCase;
24
use OCA\Mail\HordeTranslationHandler;
25
26
class HordeTranslationHandlerTest extends PHPUnit_Framework_TestCase {
27
28
	private $handler;
29
30
	protected function setUp() {
31
		parent::setUp();
32
33
		$this->handler = new HordeTranslationHandler();
34
	}
35
36
	public function testT() {
37
		$message = 'Hello';
38
39
		$expected = $message;
40
		$actual = $this->handler->t($message);
41
42
		$this->assertEquals($expected, $actual);
43
	}
44
45
	public function singularPluralDataProvider() {
46
		return [
47
			[0],
48
			[1],
49
			[2],
50
		];
51
	}
52
53
	/**
54
	 * @dataProvider singularPluralDataProvider
55
	 */
56
	public function testNgettext($number) {
57
		$singular = 'mail';
58
		$plural = 'mails';
59
60
		$expected = $number > 1 ? $plural : $singular;
61
		$actual = $this->handler->ngettext($singular, $plural, $number);
62
63
		$this->assertEquals($expected, $actual);
64
	}
65
66
}
67