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