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