* upgrade patches for oracle 1.17->1.19
[mediawiki.git] / tests / phpunit / includes / TimeAdjustTest.php
blob9065e7c81da918a887044cc9b00f615e99876c13
1 <?php
3 class TimeAdjustTest extends MediaWikiTestCase {
4 static $offset;
6 public function setUp() {
7 global $wgLocalTZoffset;
8 self::$offset = $wgLocalTZoffset;
10 $this->iniSet( 'precision', 15 );
13 public function tearDown() {
14 global $wgLocalTZoffset;
15 $wgLocalTZoffset = self::$offset;
18 # Test offset usage for a given language::userAdjust
19 function testUserAdjust() {
20 global $wgLocalTZoffset, $wgContLang;
22 $wgContLang = $en = Language::factory( 'en' );
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 ),
39 foreach ( $userAdjust_tests as $data ) {
40 $wgLocalTZoffset = $data[1];
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]}"