MediaWiki REL1_32
TimeAdjustTest.php
Go to the documentation of this file.
1<?php
2
4
6 protected function setUp() {
7 parent::setUp();
8 }
9
15 public function testUserAdjust( $date, $localTZoffset, $expected ) {
16 $this->setMwGlobals( 'wgLocalTZoffset', $localTZoffset );
17
18 $this->assertEquals(
19 $expected,
20 strval( MediaWikiServices::getInstance()->getContentLanguage()->
21 userAdjust( $date, '' ) ),
22 "User adjust {$date} by {$localTZoffset} minutes should give {$expected}"
23 );
24 }
25
26 public static function dataUserAdjust() {
27 return [
28 [ '20061231235959', 0, '20061231235959' ],
29 [ '20061231235959', 5, '20070101000459' ],
30 [ '20061231235959', 15, '20070101001459' ],
31 [ '20061231235959', 60, '20070101005959' ],
32 [ '20061231235959', 90, '20070101012959' ],
33 [ '20061231235959', 120, '20070101015959' ],
34 [ '20061231235959', 540, '20070101085959' ],
35 [ '20061231235959', -5, '20061231235459' ],
36 [ '20061231235959', -30, '20061231232959' ],
37 [ '20061231235959', -60, '20061231225959' ],
38 ];
39 }
40}
Base class that store and restore the Language objects.
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
MediaWikiServices is the service locator for the application scope of MediaWiki.
static dataUserAdjust()
testUserAdjust( $date, $localTZoffset, $expected)
Test offset usage for a given Language::userAdjust dataUserAdjust Language::userAdjust.