MediaWiki
REL1_22
|
00001 <?php 00002 class XMPValidateTest extends MediaWikiTestCase { 00003 00008 public function testValidateDate( $value, $expected ) { 00009 // The method should modify $value. 00010 XMPValidate::validateDate( array(), $value, true ); 00011 $this->assertEquals( $expected, $value ); 00012 } 00013 00014 public static function provideDates() { 00015 /* For reference valid date formats are: 00016 * YYYY 00017 * YYYY-MM 00018 * YYYY-MM-DD 00019 * YYYY-MM-DDThh:mmTZD 00020 * YYYY-MM-DDThh:mm:ssTZD 00021 * YYYY-MM-DDThh:mm:ss.sTZD 00022 * (Time zone is optional) 00023 */ 00024 return array( 00025 array( '1992', '1992' ), 00026 array( '1992-04', '1992:04' ), 00027 array( '1992-02-01', '1992:02:01' ), 00028 array( '2011-09-29', '2011:09:29' ), 00029 array( '1982-12-15T20:12', '1982:12:15 20:12' ), 00030 array( '1982-12-15T20:12Z', '1982:12:15 20:12' ), 00031 array( '1982-12-15T20:12+02:30', '1982:12:15 22:42' ), 00032 array( '1982-12-15T01:12-02:30', '1982:12:14 22:42' ), 00033 array( '1982-12-15T20:12:11', '1982:12:15 20:12:11' ), 00034 array( '1982-12-15T20:12:11Z', '1982:12:15 20:12:11' ), 00035 array( '1982-12-15T20:12:11+01:10', '1982:12:15 21:22:11' ), 00036 array( '2045-12-15T20:12:11', '2045:12:15 20:12:11' ), 00037 array( '1867-06-01T15:00:00', '1867:06:01 15:00:00' ), 00038 /* some invalid ones */ 00039 array( '2001--12', null ), 00040 array( '2001-5-12', null ), 00041 array( '2001-5-12TZ', null ), 00042 array( '2001-05-12T15', null ), 00043 array( '2001-12T15:13', null ), 00044 ); 00045 } 00046 }