2010-12-14 16:26:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
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 ) {
|
|
|
|
|
global $wgContLang;
|
|
|
|
|
|
|
|
|
|
$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,
|
2013-03-22 14:23:28 +00:00
|
|
|
strval( $wgContLang->userAdjust( $date, '' ) ),
|
|
|
|
|
"User adjust {$date} by {$localTZoffset} minutes should give {$expected}"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function dataUserAdjust() {
|
|
|
|
|
return array(
|
2014-06-18 21:53:07 +00:00
|
|
|
array( '20061231235959', 0, '20061231235959' ),
|
|
|
|
|
array( '20061231235959', 5, '20070101000459' ),
|
2014-07-19 21:12:10 +00:00
|
|
|
array( '20061231235959', 15, '20070101001459' ),
|
2014-06-18 21:53:07 +00:00
|
|
|
array( '20061231235959', 60, '20070101005959' ),
|
|
|
|
|
array( '20061231235959', 90, '20070101012959' ),
|
|
|
|
|
array( '20061231235959', 120, '20070101015959' ),
|
|
|
|
|
array( '20061231235959', 540, '20070101085959' ),
|
|
|
|
|
array( '20061231235959', -5, '20061231235459' ),
|
|
|
|
|
array( '20061231235959', -30, '20061231232959' ),
|
|
|
|
|
array( '20061231235959', -60, '20061231225959' ),
|
2010-12-14 16:26:35 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|