Merge "Use parseAsBlock() instead of parse() to show the error message in OutputPage...
[lhc/web/wiklou.git] / tests / phpunit / includes / TimeAdjustTest.php
1 <?php
2
3 class TimeAdjustTest extends MediaWikiLangTestCase {
4 protected function setUp() {
5 parent::setUp();
6
7 $this->setMwGlobals( array(
8 'wgLocalTZoffset' => null,
9 'wgContLang' => Language::factory( 'en' ),
10 ) );
11
12 $this->iniSet( 'precision', 15 );
13 }
14
15 # Test offset usage for a given language::userAdjust
16 function testUserAdjust() {
17 global $wgLocalTZoffset, $wgContLang;
18
19 #  Collection of parameters for Language_t_Offset.
20 # Format: date to be formatted, localTZoffset value, expected date
21 $userAdjust_tests = array(
22 array( 20061231235959, 0, 20061231235959 ),
23 array( 20061231235959, 5, 20070101000459 ),
24 array( 20061231235959, 15, 20070101001459 ),
25 array( 20061231235959, 60, 20070101005959 ),
26 array( 20061231235959, 90, 20070101012959 ),
27 array( 20061231235959, 120, 20070101015959 ),
28 array( 20061231235959, 540, 20070101085959 ),
29 array( 20061231235959, -5, 20061231235459 ),
30 array( 20061231235959, -30, 20061231232959 ),
31 array( 20061231235959, -60, 20061231225959 ),
32 );
33
34 foreach ( $userAdjust_tests as $data ) {
35 $wgLocalTZoffset = $data[1];
36
37 $this->assertEquals(
38 strval( $data[2] ),
39 strval( $wgContLang->userAdjust( $data[0], '' ) ),
40 "User adjust {$data[0]} by {$data[1]} minutes should give {$data[2]}"
41 );
42 }
43 }
44 }