Debian Codegraph @

tests/phpunit/includes/languages/LanguageLtTest.php

raw symbols SCIP
1 <?php
2 /**
3 * @author Santhosh Thottingal
4 * @copyright Copyright © 2012, Santhosh Thottingal
5 * @file
6 */
7
8 /**
9 * @group Language
10 */
11 class LanguageLtTest extends LanguageClassesTestCase {
12 /**
13 * @dataProvider providePlural
14 * @covers \MediaWiki\Language\Language::convertPlural
15 */
16 public function testPlural( $result, $value ) {
17 $forms = [ 'one', 'few', 'other' ];
18 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
19 }
20
21 /**
22 * @dataProvider providePlural
23 * @covers \MediaWiki\Language\Language::getPluralRuleType
24 */
25 public function testGetPluralRuleType( $result, $value ) {
26 $this->assertEquals( $result, $this->getLang()->getPluralRuleType( $value ) );
27 }
28
29 public static function providePlural() {
30 return [
31 [ 'other', 0 ],
32 [ 'one', 1 ],
33 [ 'few', 2 ],
34 [ 'few', 9 ],
35 [ 'other', 10 ],
36 [ 'other', 11 ],
37 [ 'other', 20 ],
38 [ 'one', 21 ],
39 [ 'few', 32 ],
40 [ 'one', 41 ],
41 [ 'one', 40001 ],
42 ];
43 }
44
45 /**
46 * @dataProvider providePluralTwoForms
47 * @covers \MediaWiki\Language\Language::convertPlural
48 */
49 public function testOneFewPlural( $result, $value ) {
50 $forms = [ 'one', 'other' ];
51 // This fails for 21, but not sure why.
52 $this->assertEquals( $result, $this->getLang()->convertPlural( $value, $forms ) );
53 }
54
55 public static function providePluralTwoForms() {
56 return [
57 [ 'one', 1 ],
58 [ 'other', 2 ],
59 [ 'other', 15 ],
60 [ 'other', 20 ],
61 [ 'one', 21 ],
62 [ 'other', 22 ],
63 ];
64 }
65 }