MediaWiki REL1_32
LanguageArTest.php
Go to the documentation of this file.
1<?php
2
7
12 public function testFormatNum( $num, $formatted ) {
13 $this->assertEquals( $formatted, $this->getLang()->formatNum( $num ) );
14 }
15
16 public static function provideFormatNum() {
17 return [
18 [ '1234567', '١٬٢٣٤٬٥٦٧' ],
19 [ -12.89, '-١٢٫٨٩' ],
20 ];
21 }
22
28 public function testNormalize( $input, $expected ) {
29 if ( $input === $expected ) {
30 throw new Exception( 'Expected output must differ.' );
31 }
32
33 $this->setMwGlobals( 'wgFixArabicUnicode', true );
34 $this->assertSame( $expected, $this->getLang()->normalize( $input ), 'ar-normalised form' );
35
36 $this->setMwGlobals( 'wgFixArabicUnicode', false );
37 $this->assertSame( $input, $this->getLang()->normalize( $input ), 'regular normalised form' );
38 }
39
40 public static function provideNormalize() {
41 return [
42 [
43 'ﷅ',
44 'صمم',
45 ],
46 ];
47 }
48
54 public function testSprintfDate( $format, $date, $expected ) {
55 $this->assertEquals( $expected, $this->getLang()->sprintfDate( $format, $date ) );
56 }
57
58 public static function provideSprintfDate() {
59 return [
60 [
61 'xg "vs" g',
62 '20120102030410',
63 'يناير vs ٣'
64 ],
65 [
66 'xmY',
67 '20120102030410',
68 '١٤٣٣'
69 ],
70 [
71 'xnxmY',
72 '20120102030410',
73 '1433'
74 ],
75 [
76 'xN xmj xmn xN xmY',
77 '20120102030410',
78 ' 7 2 ١٤٣٣'
79 ],
80 ];
81 }
82
87 public function testPlural( $result, $value ) {
88 $forms = [ 'zero', 'one', 'two', 'few', 'many', 'other' ];
89 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
90 }
91
96 public function testGetPluralRuleType( $result, $value ) {
97 $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
98 }
99
100 public static function providePlural() {
101 return [
102 [ 'zero', 0 ],
103 [ 'one', 1 ],
104 [ 'two', 2 ],
105 [ 'few', 3 ],
106 [ 'few', 9 ],
107 [ 'few', 110 ],
108 [ 'many', 11 ],
109 [ 'many', 15 ],
110 [ 'many', 99 ],
111 [ 'many', 9999 ],
112 [ 'other', 100 ],
113 [ 'other', 102 ],
114 [ 'other', 1000 ],
115 [ 'other', 1.7 ],
116 ];
117 }
118}
static provideNormalize()
static provideSprintfDate()
testNormalize( $input, $expected)
LanguageAr::normalize Language::normalize provideNormalize.
testFormatNum( $num, $formatted)
Language::formatNum provideFormatNum.
testPlural( $result, $value)
providePlural Language::convertPlural
static provideFormatNum()
testSprintfDate( $format, $date, $expected)
Mostly to test the raw ascii feature.
testGetPluralRuleType( $result, $value)
providePlural Language::getPluralRuleType
Helping class to run tests using a clean language instance.
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
if(is_array($mode)) switch( $mode) $input