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