Add @covers tags to languages tests
[lhc/web/wiklou.git] / tests / phpunit / languages / classes / LanguageArTest.php
1 <?php
2 /**
3 * Based on LanguagMlTest
4 * @file
5 */
6
7 /**
8 * @covers LanguageAr
9 */
10 class LanguageArTest extends LanguageClassesTestCase {
11 /**
12 * @covers Language::formatNum
13 * @todo split into a test and a dataprovider
14 */
15 public function testFormatNum() {
16 $this->assertEquals( '١٬٢٣٤٬٥٦٧', $this->getLang()->formatNum( '1234567' ) );
17 $this->assertEquals( '-١٢٫٨٩', $this->getLang()->formatNum( -12.89 ) );
18 }
19
20 /**
21 * Mostly to test the raw ascii feature.
22 * @dataProvider providerSprintfDate
23 * @covers Language::sprintfDate
24 */
25 public function testSprintfDate( $format, $date, $expected ) {
26 $this->assertEquals( $expected, $this->getLang()->sprintfDate( $format, $date ) );
27 }
28
29 public static function providerSprintfDate() {
30 return [
31 [
32 'xg "vs" g',
33 '20120102030410',
34 'يناير vs ٣'
35 ],
36 [
37 'xmY',
38 '20120102030410',
39 '١٤٣٣'
40 ],
41 [
42 'xnxmY',
43 '20120102030410',
44 '1433'
45 ],
46 [
47 'xN xmj xmn xN xmY',
48 '20120102030410',
49 ' 7 2 ١٤٣٣'
50 ],
51 ];
52 }
53
54 /**
55 * @dataProvider providePlural
56 * @covers Language::convertPlural
57 */
58 public function testPlural( $result, $value ) {
59 $forms = [ 'zero', 'one', 'two', 'few', 'many', 'other' ];
60 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
61 }
62
63 /**
64 * @dataProvider providePlural
65 * @covers Language::getPluralRuleType
66 */
67 public function testGetPluralRuleType( $result, $value ) {
68 $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
69 }
70
71 public static function providePlural() {
72 return [
73 [ 'zero', 0 ],
74 [ 'one', 1 ],
75 [ 'two', 2 ],
76 [ 'few', 3 ],
77 [ 'few', 9 ],
78 [ 'few', 110 ],
79 [ 'many', 11 ],
80 [ 'many', 15 ],
81 [ 'many', 99 ],
82 [ 'many', 9999 ],
83 [ 'other', 100 ],
84 [ 'other', 102 ],
85 [ 'other', 1000 ],
86 [ 'other', 1.7 ],
87 ];
88 }
89 }