Merge "Parser test to test language conversion around HTML tags."
[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 'wgLanguageCode' => 'en',
11 ) );
12
13 $this->iniSet( 'precision', 15 );
14 }
15
16 # Test offset usage for a given language::userAdjust
17 function testUserAdjust() {
18 global $wgLocalTZoffset, $wgContLang;
19
20 #  Collection of parameters for Language_t_Offset.
21 # Format: date to be formatted, localTZoffset value, expected date
22 $userAdjust_tests = array(
23 array( 20061231235959, 0, 20061231235959 ),
24 array( 20061231235959, 5, 20070101000459 ),
25 array( 20061231235959, 15, 20070101001459 ),
26 array( 20061231235959, 60, 20070101005959 ),
27 array( 20061231235959, 90, 20070101012959 ),
28 array( 20061231235959, 120, 20070101015959 ),
29 array( 20061231235959, 540, 20070101085959 ),
30 array( 20061231235959, -5, 20061231235459 ),
31 array( 20061231235959, -30, 20061231232959 ),
32 array( 20061231235959, -60, 20061231225959 ),
33 );
34
35 foreach ( $userAdjust_tests as $data ) {
36 $wgLocalTZoffset = $data[1];
37
38 $this->assertEquals(
39 strval( $data[2] ),
40 strval( $wgContLang->userAdjust( $data[0], '' ) ),
41 "User adjust {$data[0]} by {$data[1]} minutes should give {$data[2]}"
42 );
43 }
44 }
45 }