8e30259b17a8a46ec5b248ffe3f5ac339306b84e
[lhc/web/wiklou.git] / tests / phpunit / languages / LanguageTest.php
1 <?php
2 require_once dirname(dirname(__FILE__)). '/bootstrap.php';
3
4 class LanguageTest extends MediaWikiTestSetup {
5 private $lang;
6
7 function setUp() {
8 $this->lang = Language::factory( 'en' );
9 }
10 function tearDown() {
11 unset( $this->lang );
12 }
13
14 function testLanguageConvertDoubleWidthToSingleWidth() {
15 $this->assertEquals(
16 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
17 $this->lang->normalizeForSearch(
18 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
19 ),
20 'convertDoubleWidth() with the full alphabet and digits'
21 );
22 }
23
24 function testFormatTimePeriod() {
25 $this->assertEquals(
26 "9.5s",
27 $this->lang->formatTimePeriod( 9.45 ),
28 'formatTimePeriod() rounding (<10s)'
29 );
30
31 $this->assertEquals(
32 "10s",
33 $this->lang->formatTimePeriod( 9.95 ),
34 'formatTimePeriod() rounding (<10s)'
35 );
36
37 $this->assertEquals(
38 "1m 0s",
39 $this->lang->formatTimePeriod( 59.55 ),
40 'formatTimePeriod() rounding (<60s)'
41 );
42
43 $this->assertEquals(
44 "2m 0s",
45 $this->lang->formatTimePeriod( 119.55 ),
46 'formatTimePeriod() rounding (<1h)'
47 );
48
49 $this->assertEquals(
50 "1h 0m 0s",
51 $this->lang->formatTimePeriod( 3599.55 ),
52 'formatTimePeriod() rounding (<1h)'
53 );
54
55 $this->assertEquals(
56 "2h 0m 0s",
57 $this->lang->formatTimePeriod( 7199.55 ),
58 'formatTimePeriod() rounding (>=1h)'
59 );
60 }
61 }