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

« back to all changes in this revision

Viewing changes to tests/phpunit/includes/media/XMPValidateTest.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
class XMPValidateTest extends MediaWikiTestCase {
 
3
 
 
4
        /**
 
5
         * @dataProvider providerDate
 
6
         */
 
7
        function testValidateDate( $value, $expected ) {
 
8
                // The method should modify $value.
 
9
                XMPValidate::validateDate( array(), $value, true );
 
10
                $this->assertEquals( $expected, $value );
 
11
        }
 
12
 
 
13
        function providerDate() {
 
14
                /* For reference valid date formats are:
 
15
                 * YYYY
 
16
                 * YYYY-MM
 
17
                 * YYYY-MM-DD
 
18
                 * YYYY-MM-DDThh:mmTZD
 
19
                 * YYYY-MM-DDThh:mm:ssTZD
 
20
                 * YYYY-MM-DDThh:mm:ss.sTZD
 
21
                 * (Time zone is optional)
 
22
                 */
 
23
                return array(
 
24
                        array( '1992', '1992' ),
 
25
                        array( '1992-04', '1992:04' ),
 
26
                        array( '1992-02-01', '1992:02:01' ),
 
27
                        array( '2011-09-29', '2011:09:29' ),
 
28
                        array( '1982-12-15T20:12', '1982:12:15 20:12' ),
 
29
                        array( '1982-12-15T20:12Z', '1982:12:15 20:12' ),
 
30
                        array( '1982-12-15T20:12+02:30', '1982:12:15 22:42' ),
 
31
                        array( '1982-12-15T01:12-02:30', '1982:12:14 22:42' ),
 
32
                        array( '1982-12-15T20:12:11', '1982:12:15 20:12:11' ),
 
33
                        array( '1982-12-15T20:12:11Z', '1982:12:15 20:12:11' ),
 
34
                        array( '1982-12-15T20:12:11+01:10', '1982:12:15 21:22:11' ),
 
35
                        array( '2045-12-15T20:12:11', '2045:12:15 20:12:11' ),
 
36
                        array( '1867-06-01T15:00:00', '1867:06:01 15:00:00' ),
 
37
                        /* some invalid ones */
 
38
                        array( '2001--12', null ),
 
39
                        array( '2001-5-12', null ),
 
40
                        array( '2001-5-12TZ', null ),
 
41
                        array( '2001-05-12T15', null ),
 
42
                        array( '2001-12T15:13', null ),
 
43
                );
 
44
 
 
45
        }
 
46
 
 
47
}