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