Debian Codegraph @

tests/phpunit/includes/languages/LanguageApcTest.php

raw symbols SCIP
1 <?php
2
3 /**
4 * @group Language
5 */
6 class LanguageApcTest extends LanguageClassesTestCase {
7
8 /**
9 * @covers \MediaWiki\Language\Language::formatNum
10 * @dataProvider provideFormatNum
11 */
12 public function testFormatNum( $num, $formatted ) {
13 $this->assertEquals( $formatted, $this->getLang()->formatNum( $num ) );
14 }
15
16 public static function provideFormatNum() {
17 // Check that the Western numbers don't change in transformation
18 // https://phabricator.wikimedia.org/T382781
19 return [
20 [ '1234567890', '1,234,567,890' ],
21 [ -12.89, '−12.89' ],
22 [ '1289.456', '1,289.456' ]
23 ];
24 }
25
26 /**
27 * @dataProvider providePlural
28 * @covers \MediaWiki\Language\Language::convertPlural
29 */
30 public function testPlural( $result, $value ) {
31 $forms = [ 'one', 'two', 'few', 'other' ];
32 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
33 }
34
35 /**
36 * @dataProvider providePlural
37 * @covers \MediaWiki\Language\Language::getPluralRuleType
38 */
39 public function testGetPluralRuleType( $result, $value ) {
40 $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
41 }
42
43 public static function providePlural() {
44 return [
45 [ 'few', 0 ],
46 [ 'one', 1 ],
47 [ 'two', 2 ],
48 [ 'few', 3 ],
49 [ 'few', 9 ],
50 [ 'few', 10 ],
51 [ 'other', 11 ],
52 [ 'other', 12 ],
53 [ 'other', 99 ],
54 [ 'other', 100 ],
55 [ 'other', 101 ],
56 [ 'other', 102 ],
57 [ 'few', 103 ],
58 [ 'few', 104 ],
59 [ 'few', 109 ],
60 [ 'few', 110 ],
61 [ 'other', 111 ],
62 [ 'other', 112 ],
63 [ 'other', 9999 ],
64 [ 'other', 1000 ],
65 [ 'few', 1003 ],
66 [ 'other', 1.7 ],
67 ];
68 }
69 }