~ubuntu-branches/ubuntu/trusty/mediawiki/trusty-proposed

« back to all changes in this revision

Viewing changes to tests/phpunit/includes/TimeAdjustTest.php

  • Committer: Package Import Robot
  • Author(s): Thorsten Glaser
  • Date: 2014-03-28 09:56:29 UTC
  • mfrom: (1.3.14)
  • Revision ID: package-import@ubuntu.com-20140328095629-1526y9tchdd507id
Tags: 1:1.19.14+dfsg-1
* New upstream security fix release (Closes: #742857):
  - (bug 62497) SECURITY: Add CSRF token on Special:ChangePassword
  - (bug 62467) Set a title for the context during import on the cli
* Use upstream-provided signing key bundle

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
class TimeAdjustTest extends MediaWikiLangTestCase {
 
4
        static $offset;
 
5
 
 
6
        public function setUp() {
 
7
                parent::setUp();
 
8
                global $wgLocalTZoffset;
 
9
                self::$offset = $wgLocalTZoffset;
 
10
 
 
11
                $this->iniSet( 'precision', 15 );
 
12
        }
 
13
 
 
14
        public function tearDown() {
 
15
                global $wgLocalTZoffset;
 
16
                $wgLocalTZoffset = self::$offset;
 
17
                parent::tearDown();
 
18
        }
 
19
 
 
20
        # Test offset usage for a given language::userAdjust
 
21
        function testUserAdjust() {
 
22
                global $wgLocalTZoffset, $wgContLang;
 
23
 
 
24
                $wgContLang = $en = Language::factory( 'en' );
 
25
 
 
26
                #  Collection of parameters for Language_t_Offset.
 
27
                # Format: date to be formatted, localTZoffset value, expected date
 
28
                $userAdjust_tests = array(
 
29
                        array( 20061231235959,   0, 20061231235959 ),
 
30
                        array( 20061231235959,   5, 20070101000459 ),
 
31
                        array( 20061231235959,  15, 20070101001459 ),
 
32
                        array( 20061231235959,  60, 20070101005959 ),
 
33
                        array( 20061231235959,  90, 20070101012959 ),
 
34
                        array( 20061231235959, 120, 20070101015959 ),
 
35
                        array( 20061231235959, 540, 20070101085959 ),
 
36
                        array( 20061231235959,  -5, 20061231235459 ),
 
37
                        array( 20061231235959, -30, 20061231232959 ),
 
38
                        array( 20061231235959, -60, 20061231225959 ),
 
39
                );
 
40
 
 
41
                foreach ( $userAdjust_tests as $data ) {
 
42
                        $wgLocalTZoffset = $data[1];
 
43
 
 
44
                        $this->assertEquals(
 
45
                                strval( $data[2] ),
 
46
                                strval( $en->userAdjust( $data[0], '' ) ),
 
47
                                "User adjust {$data[0]} by {$data[1]} minutes should give {$data[2]}"
 
48
                        );
 
49
                }
 
50
        }
 
51
}