MediaWiki REL1_33
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->hideDeprecated( '$wgFixArabicUnicode = false' );
38 $this->assertSame( $input, $this->getLang()->normalize( $input ), 'regular normalised form' );
39 }
40
41 public static function provideNormalize() {
42 return [
43 [
44 'ﷅ',
45 'صمم',
46 ],
47 ];
48 }
49
55 public function testSprintfDate( $format, $date, $expected ) {
56 $this->assertEquals( $expected, $this->getLang()->sprintfDate( $format, $date ) );
57 }
58
59 public static function provideSprintfDate() {
60 return [
61 [
62 'xg "vs" g',
63 '20120102030410',
64 'يناير vs ٣'
65 ],
66 [
67 'xmY',
68 '20120102030410',
69 '١٤٣٣'
70 ],
71 [
72 'xnxmY',
73 '20120102030410',
74 '1433'
75 ],
76 [
77 'xN xmj xmn xN xmY',
78 '20120102030410',
79 ' 7 2 ١٤٣٣'
80 ],
81 ];
82 }
83
88 public function testPlural( $result, $value ) {
89 $forms = [ 'zero', 'one', 'two', 'few', 'many', 'other' ];
90 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
91 }
92
97 public function testGetPluralRuleType( $result, $value ) {
98 $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
99 }
100
101 public static function providePlural() {
102 return [
103 [ 'zero', 0 ],
104 [ 'one', 1 ],
105 [ 'two', 2 ],
106 [ 'few', 3 ],
107 [ 'few', 9 ],
108 [ 'few', 110 ],
109 [ 'many', 11 ],
110 [ 'many', 15 ],
111 [ 'many', 99 ],
112 [ 'many', 9999 ],
113 [ 'other', 100 ],
114 [ 'other', 102 ],
115 [ 'other', 1000 ],
116 [ 'other', 1.7 ],
117 ];
118 }
119}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
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.
hideDeprecated( $function)
Don't throw a warning if $function is deprecated and called later.
if(is_array($mode)) switch( $mode) $input