2010-12-14 16:26:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
2018-07-29 12:24:54 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
|
2011-06-14 21:21:26 +00:00
|
|
|
class TimeAdjustTest extends MediaWikiLangTestCase {
|
2012-10-08 10:56:20 +00:00
|
|
|
protected function setUp() {
|
2011-06-15 20:51:17 +00:00
|
|
|
parent::setUp();
|
2010-12-14 16:26:35 +00:00
|
|
|
}
|
|
|
|
|
|
2013-03-22 14:23:28 +00:00
|
|
|
/**
|
2013-10-21 21:09:13 +00:00
|
|
|
* Test offset usage for a given Language::userAdjust
|
2013-03-22 14:23:28 +00:00
|
|
|
* @dataProvider dataUserAdjust
|
2013-10-21 21:09:13 +00:00
|
|
|
* @covers Language::userAdjust
|
2013-03-22 14:23:28 +00:00
|
|
|
*/
|
|
|
|
|
public function testUserAdjust( $date, $localTZoffset, $expected ) {
|
|
|
|
|
$this->setMwGlobals( 'wgLocalTZoffset', $localTZoffset );
|
2010-12-14 16:26:35 +00:00
|
|
|
|
2013-03-22 14:23:28 +00:00
|
|
|
$this->assertEquals(
|
2014-06-18 21:53:07 +00:00
|
|
|
$expected,
|
2018-07-29 12:24:54 +00:00
|
|
|
strval( MediaWikiServices::getInstance()->getContentLanguage()->
|
|
|
|
|
userAdjust( $date, '' ) ),
|
2013-03-22 14:23:28 +00:00
|
|
|
"User adjust {$date} by {$localTZoffset} minutes should give {$expected}"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function dataUserAdjust() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
|
|
|
|
[ '20061231235959', 0, '20061231235959' ],
|
|
|
|
|
[ '20061231235959', 5, '20070101000459' ],
|
|
|
|
|
[ '20061231235959', 15, '20070101001459' ],
|
|
|
|
|
[ '20061231235959', 60, '20070101005959' ],
|
|
|
|
|
[ '20061231235959', 90, '20070101012959' ],
|
|
|
|
|
[ '20061231235959', 120, '20070101015959' ],
|
|
|
|
|
[ '20061231235959', 540, '20070101085959' ],
|
|
|
|
|
[ '20061231235959', -5, '20061231235459' ],
|
|
|
|
|
[ '20061231235959', -30, '20061231232959' ],
|
|
|
|
|
[ '20061231235959', -60, '20061231225959' ],
|
|
|
|
|
];
|
2010-12-14 16:26:35 +00:00
|
|
|
}
|
|
|
|
|
}
|