protected function setUp() {
parent::setUp();
+ // Avoid 'GetHumanTimestamp' hook and others
+ $this->setMwGlobals( 'wgHooks', array() );
+
RequestContext::getMain()->setLanguage( Language::factory( 'en' ) );
}
$this->assertEquals( '1406833268', $timestamp->__toString() );
}
- public function provideValidTimestampDifferences() {
+ public static function provideValidTimestampDifferences() {
return array(
array( '1406833268', '1406833269', '00 00 00 01' ),
array( '1406833268', '1406833329', '00 00 01 01' ),
new MWTimestamp( "This is not a timestamp." );
}
+ /**
+ * Test an out of range timestamp
+ * @dataProvider provideOutOfRangeTimestamps
+ * @expectedException TimestampException
+ * @covers MWTimestamp
+ */
+ public function testOutOfRangeTimestamps( $format, $input ) {
+ $timestamp = new MWTimestamp( $input );
+ $timestamp->getTimestamp( $format );
+ }
+
/**
* Test requesting an invalid output format.
* @expectedException TimestampException
);
}
+ /**
+ * Returns a list of out of range timestamps in the format:
+ * array( type, timestamp_of_type )
+ */
+ public static function provideOutOfRangeTimestamps() {
+ return array(
+ // Various formats
+ array( TS_MW, '-62167219201' ), // -0001-12-31T23:59:59Z
+ array( TS_MW, '253402300800' ), // 10000-01-01T00:00:00Z
+ );
+ }
+
/**
* @dataProvider provideHumanTimestampTests
* @covers MWTimestamp::getHumanTimestamp