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