MediaWiki
REL1_21
|
00001 <?php 00002 00003 class TimeAdjustTest extends MediaWikiLangTestCase { 00004 protected function setUp() { 00005 parent::setUp(); 00006 00007 $this->setMwGlobals( array( 00008 'wgLocalTZoffset' => null, 00009 'wgContLang' => Language::factory( 'en' ), 00010 'wgLanguageCode' => 'en', 00011 ) ); 00012 00013 $this->iniSet( 'precision', 15 ); 00014 } 00015 00016 # Test offset usage for a given language::userAdjust 00017 function testUserAdjust() { 00018 global $wgLocalTZoffset, $wgContLang; 00019 00020 # Collection of parameters for Language_t_Offset. 00021 # Format: date to be formatted, localTZoffset value, expected date 00022 $userAdjust_tests = array( 00023 array( 20061231235959, 0, 20061231235959 ), 00024 array( 20061231235959, 5, 20070101000459 ), 00025 array( 20061231235959, 15, 20070101001459 ), 00026 array( 20061231235959, 60, 20070101005959 ), 00027 array( 20061231235959, 90, 20070101012959 ), 00028 array( 20061231235959, 120, 20070101015959 ), 00029 array( 20061231235959, 540, 20070101085959 ), 00030 array( 20061231235959, -5, 20061231235459 ), 00031 array( 20061231235959, -30, 20061231232959 ), 00032 array( 20061231235959, -60, 20061231225959 ), 00033 ); 00034 00035 foreach ( $userAdjust_tests as $data ) { 00036 $wgLocalTZoffset = $data[1]; 00037 00038 $this->assertEquals( 00039 strval( $data[2] ), 00040 strval( $wgContLang->userAdjust( $data[0], '' ) ), 00041 "User adjust {$data[0]} by {$data[1]} minutes should give {$data[2]}" 00042 ); 00043 } 00044 } 00045 }