2 class XMPValidateTest
extends MediaWikiTestCase
{
5 * @dataProvider provideDates
6 * @covers XMPValidate::validateDate
8 public function testValidateDate( $value, $expected ) {
9 // The method should modify $value.
10 XMPValidate
::validateDate( array(), $value, true );
11 $this->assertEquals( $expected, $value );
14 public static function provideDates() {
15 /* For reference valid date formats are:
20 * YYYY-MM-DDThh:mm:ssTZD
21 * YYYY-MM-DDThh:mm:ss.sTZD
22 * (Time zone is optional)
25 array( '1992', '1992' ),
26 array( '1992-04', '1992:04' ),
27 array( '1992-02-01', '1992:02:01' ),
28 array( '2011-09-29', '2011:09:29' ),
29 array( '1982-12-15T20:12', '1982:12:15 20:12' ),
30 array( '1982-12-15T20:12Z', '1982:12:15 20:12' ),
31 array( '1982-12-15T20:12+02:30', '1982:12:15 22:42' ),
32 array( '1982-12-15T01:12-02:30', '1982:12:14 22:42' ),
33 array( '1982-12-15T20:12:11', '1982:12:15 20:12:11' ),
34 array( '1982-12-15T20:12:11Z', '1982:12:15 20:12:11' ),
35 array( '1982-12-15T20:12:11+01:10', '1982:12:15 21:22:11' ),
36 array( '2045-12-15T20:12:11', '2045:12:15 20:12:11' ),
37 array( '1867-06-01T15:00:00', '1867:06:01 15:00:00' ),
38 /* some invalid ones */
39 array( '2001--12', null ),
40 array( '2001-5-12', null ),
41 array( '2001-5-12TZ', null ),
42 array( '2001-05-12T15', null ),
43 array( '2001-12T15:13', null ),