Remove useless bootstrap inclusions
[lhc/web/wiklou.git] / tests / phpunit / languages / LanguageTest.php
1 <?php
2
3 class LanguageTest extends MediaWikiTestCase {
4 private $lang;
5
6 function setUp() {
7 $this->lang = Language::factory( 'en' );
8 }
9 function tearDown() {
10 unset( $this->lang );
11 }
12
13 function testLanguageConvertDoubleWidthToSingleWidth() {
14 $this->assertEquals(
15 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
16 $this->lang->normalizeForSearch(
17 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
18 ),
19 'convertDoubleWidth() with the full alphabet and digits'
20 );
21 }
22
23 function testFormatTimePeriod() {
24 $this->assertEquals(
25 "9.5s",
26 $this->lang->formatTimePeriod( 9.45 ),
27 'formatTimePeriod() rounding (<10s)'
28 );
29
30 $this->assertEquals(
31 "10s",
32 $this->lang->formatTimePeriod( 9.95 ),
33 'formatTimePeriod() rounding (<10s)'
34 );
35
36 $this->assertEquals(
37 "1m 0s",
38 $this->lang->formatTimePeriod( 59.55 ),
39 'formatTimePeriod() rounding (<60s)'
40 );
41
42 $this->assertEquals(
43 "2m 0s",
44 $this->lang->formatTimePeriod( 119.55 ),
45 'formatTimePeriod() rounding (<1h)'
46 );
47
48 $this->assertEquals(
49 "1h 0m 0s",
50 $this->lang->formatTimePeriod( 3599.55 ),
51 'formatTimePeriod() rounding (<1h)'
52 );
53
54 $this->assertEquals(
55 "2h 0m 0s",
56 $this->lang->formatTimePeriod( 7199.55 ),
57 'formatTimePeriod() rounding (>=1h)'
58 );
59 }
60
61 /**
62 * Test Language::isValidBuiltInCode()
63 * @dataProvider provideLanguageCodes
64 */
65 function testBuiltInCodeValidation( $code, $message = '' ) {
66 $this->assertTrue(
67 (bool) Language::isValidBuiltInCode( $code ),
68 "validating code $code $message"
69 );
70 }
71
72 function testBuiltInCodeValidationRejectUnderscore() {
73 $this->assertFalse(
74 (bool) Language::isValidBuiltInCode( 'be_tarask' ),
75 "reject underscore in language code"
76 );
77 }
78
79 function provideLanguageCodes() {
80 return array(
81 array( 'fr' , 'Two letters, minor case' ),
82 array( 'EN' , 'Two letters, upper case' ),
83 array( 'tyv' , 'Three letters' ),
84 array( 'tokipona' , 'long language code' ),
85 array( 'be-tarask', 'With dash' ),
86 array( 'Zh-classical', 'Begin with upper case, dash' ),
87 array( 'Be-x-old', 'With extension (two dashes)' ),
88 );
89 }
90 }