MediaWiki REL1_30
XMPValidateTest.php
Go to the documentation of this file.
1<?php
2
3use Psr\Log\NullLogger;
4
8class XMPValidateTest extends PHPUnit_Framework_TestCase {
9
14 public function testValidateDate( $value, $expected ) {
15 // The method should modify $value.
16 $validate = new XMPValidate( new NullLogger() );
17 $validate->validateDate( [], $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 [
32 [ '1992', '1992' ],
33 [ '1992-04', '1992:04' ],
34 [ '1992-02-01', '1992:02:01' ],
35 [ '2011-09-29', '2011:09:29' ],
36 [ '1982-12-15T20:12', '1982:12:15 20:12' ],
37 [ '1982-12-15T20:12Z', '1982:12:15 20:12' ],
38 [ '1982-12-15T20:12+02:30', '1982:12:15 22:42' ],
39 [ '1982-12-15T01:12-02:30', '1982:12:14 22:42' ],
40 [ '1982-12-15T20:12:11', '1982:12:15 20:12:11' ],
41 [ '1982-12-15T20:12:11Z', '1982:12:15 20:12:11' ],
42 [ '1982-12-15T20:12:11+01:10', '1982:12:15 21:22:11' ],
43 [ '2045-12-15T20:12:11', '2045:12:15 20:12:11' ],
44 [ '1867-06-01T15:00:00', '1867:06:01 15:00:00' ],
45 /* some invalid ones */
46 [ '2001--12', null ],
47 [ '2001-5-12', null ],
48 [ '2001-5-12TZ', null ],
49 [ '2001-05-12T15', null ],
50 [ '2001-12T15:13', null ],
51 ];
52 }
53}
testValidateDate( $value, $expected)
provideDates XMPValidate::validateDate
This contains some static methods for validating XMP properties.