Merge "Use Xml::element instead of Html::element for empty elements"
[lhc/web/wiklou.git] / tests / phpunit / includes / media / XMPValidateTest.php
1 <?php
2
3 /**
4 * @group Media
5 */
6 class XMPValidateTest extends MediaWikiTestCase {
7
8 /**
9 * @dataProvider provideDates
10 * @covers XMPValidate::validateDate
11 */
12 public function testValidateDate( $value, $expected ) {
13 // The method should modify $value.
14 XMPValidate::validateDate( array(), $value, true );
15 $this->assertEquals( $expected, $value );
16 }
17
18 public static function provideDates() {
19 /* For reference valid date formats are:
20 * YYYY
21 * YYYY-MM
22 * YYYY-MM-DD
23 * YYYY-MM-DDThh:mmTZD
24 * YYYY-MM-DDThh:mm:ssTZD
25 * YYYY-MM-DDThh:mm:ss.sTZD
26 * (Time zone is optional)
27 */
28 return array(
29 array( '1992', '1992' ),
30 array( '1992-04', '1992:04' ),
31 array( '1992-02-01', '1992:02:01' ),
32 array( '2011-09-29', '2011:09:29' ),
33 array( '1982-12-15T20:12', '1982:12:15 20:12' ),
34 array( '1982-12-15T20:12Z', '1982:12:15 20:12' ),
35 array( '1982-12-15T20:12+02:30', '1982:12:15 22:42' ),
36 array( '1982-12-15T01:12-02:30', '1982:12:14 22:42' ),
37 array( '1982-12-15T20:12:11', '1982:12:15 20:12:11' ),
38 array( '1982-12-15T20:12:11Z', '1982:12:15 20:12:11' ),
39 array( '1982-12-15T20:12:11+01:10', '1982:12:15 21:22:11' ),
40 array( '2045-12-15T20:12:11', '2045:12:15 20:12:11' ),
41 array( '1867-06-01T15:00:00', '1867:06:01 15:00:00' ),
42 /* some invalid ones */
43 array( '2001--12', null ),
44 array( '2001-5-12', null ),
45 array( '2001-5-12TZ', null ),
46 array( '2001-05-12T15', null ),
47 array( '2001-12T15:13', null ),
48 );
49 }
50 }