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
|
|
|
|
2012-10-08 10:56:20 +00:00
|
|
|
$this->iniSet( 'precision', 15 );
|
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(
|
|
|
|
|
strval( $expected ),
|
|
|
|
|
strval( $wgContLang->userAdjust( $date, '' ) ),
|
|
|
|
|
"User adjust {$date} by {$localTZoffset} minutes should give {$expected}"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function dataUserAdjust() {
|
|
|
|
|
return array(
|
2013-02-14 11:36:35 +00:00
|
|
|
array( 20061231235959, 0, 20061231235959 ),
|
|
|
|
|
array( 20061231235959, 5, 20070101000459 ),
|
|
|
|
|
array( 20061231235959, 15, 20070101001459 ),
|
|
|
|
|
array( 20061231235959, 60, 20070101005959 ),
|
|
|
|
|
array( 20061231235959, 90, 20070101012959 ),
|
2010-12-14 16:26:35 +00:00
|
|
|
array( 20061231235959, 120, 20070101015959 ),
|
|
|
|
|
array( 20061231235959, 540, 20070101085959 ),
|
2013-02-14 11:36:35 +00:00
|
|
|
array( 20061231235959, -5, 20061231235459 ),
|
2010-12-14 16:26:35 +00:00
|
|
|
array( 20061231235959, -30, 20061231232959 ),
|
|
|
|
|
array( 20061231235959, -60, 20061231225959 ),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|