Merge "HTMLCheckMatrix support for forcing options on/off"
[lhc/web/wiklou.git] / tests / phpunit / includes / media / XMPValidateTest.php
1 <?php
2 class XMPValidateTest extends MediaWikiTestCase {
3
4 /**
5 * @dataProvider provideDates
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 public static function provideDates() {
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 }