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