Added merge() function to BagOStuff for CAS-like functionality.
[mediawiki.git] / tests / phpunit / includes / TimeAdjustTest.php
blob07ce84bf02959a5ee9e9108d66a95dbef8e481b9
1 <?php
3 class TimeAdjustTest extends MediaWikiLangTestCase {
4 protected function setUp() {
5 parent::setUp();
7 $this->setMwGlobals( array(
8 'wgLocalTZoffset' => null,
9 'wgContLang' => Language::factory( 'en' ),
10 'wgLanguageCode' => 'en',
11 ) );
13 $this->iniSet( 'precision', 15 );
16 # Test offset usage for a given language::userAdjust
17 function testUserAdjust() {
18 global $wgLocalTZoffset, $wgContLang;
20 #  Collection of parameters for Language_t_Offset.
21 # Format: date to be formatted, localTZoffset value, expected date
22 $userAdjust_tests = array(
23 array( 20061231235959, 0, 20061231235959 ),
24 array( 20061231235959, 5, 20070101000459 ),
25 array( 20061231235959, 15, 20070101001459 ),
26 array( 20061231235959, 60, 20070101005959 ),
27 array( 20061231235959, 90, 20070101012959 ),
28 array( 20061231235959, 120, 20070101015959 ),
29 array( 20061231235959, 540, 20070101085959 ),
30 array( 20061231235959, -5, 20061231235459 ),
31 array( 20061231235959, -30, 20061231232959 ),
32 array( 20061231235959, -60, 20061231225959 ),
35 foreach ( $userAdjust_tests as $data ) {
36 $wgLocalTZoffset = $data[1];
38 $this->assertEquals(
39 strval( $data[2] ),
40 strval( $wgContLang->userAdjust( $data[0], '' ) ),
41 "User adjust {$data[0]} by {$data[1]} minutes should give {$data[2]}"