3 class TimeAdjustTest
extends MediaWikiLangTestCase
{
4 static $offset, $timezone;
6 public function setUp() {
8 global $wgLocalTZoffset, $wgLocaltimezone;
9 self
::$offset = $wgLocalTZoffset;
10 self
::$timezone = $wgLocaltimezone;
12 $this->iniSet( 'precision', 15 );
15 public function tearDown() {
16 global $wgLocalTZoffset, $wgLocaltimezone;
17 $wgLocalTZoffset = self
::$offset;
18 $wgLocaltimezone = self
::$timezone;
23 * Test offset usage for a given language::userAdjust
24 * @dataProvider dataUserAdjustWithOffset
26 function testUserAdjustWithOffset( $inputDate, $offset, $expectedDate ) {
27 global $wgLocalTZoffset, $wgLocaltimezone, $wgContLang;
29 $wgContLang = $en = Language
::factory( 'en' );
31 $wgLocaltimezone = 'DummyTimezoneSoUserAdjustWillUseTzOffset';
32 $wgLocalTZoffset = $offset;
35 strval( $expectedDate ),
36 strval( $en->userAdjust( $inputDate, '' ) ),
37 "User adjust {$inputDate} by {$offset} minutes should give {$expectedDate}"
41 function dataUserAdjustWithOffset() {
42 # Collection of parameters for Language_t_Offset.
43 # Format: date to be formatted, localTZoffset value, expected date
45 array( 20061231235959, 0, 20061231235959 ),
46 array( 20061231235959, 5, 20070101000459 ),
47 array( 20061231235959, 15, 20070101001459 ),
48 array( 20061231235959, 60, 20070101005959 ),
49 array( 20061231235959, 90, 20070101012959 ),
50 array( 20061231235959, 120, 20070101015959 ),
51 array( 20061231235959, 540, 20070101085959 ),
52 array( 20061231235959, -5, 20061231235459 ),
53 array( 20061231235959, -30, 20061231232959 ),
54 array( 20061231235959, -60, 20061231225959 ),
59 * Test timezone usage for a given language::userAdjust
60 * @dataProvider dataUserAdjustWithTimezone
62 function testUserAdjustWithTimezone( $inputDate, $timezone, $expectedDate ) {
63 global $wgLocalTZoffset, $wgLocaltimezone;
65 $wgContLang = $en = Language
::factory( 'en' );
67 $wgLocaltimezone = $timezone;
71 strval( $expectedDate ),
72 strval( $en->userAdjust( $inputDate, '' ) ),
73 "User adjust {$inputDate} with timezone {$timezone} should give {$expectedDate}"
77 function dataUserAdjustWithTimezone() {
79 array( 20111028233711, 'Europe/Warsaw', 20111029013711 ),
80 array( 20111108205929, 'Europe/Warsaw', 20111108215929 ),