diff options
Diffstat (limited to 'tests/phpunit/includes/MWTimestampTest.php')
-rw-r--r-- | tests/phpunit/includes/MWTimestampTest.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/phpunit/includes/MWTimestampTest.php b/tests/phpunit/includes/MWTimestampTest.php index dcb98563..36562545 100644 --- a/tests/phpunit/includes/MWTimestampTest.php +++ b/tests/phpunit/includes/MWTimestampTest.php @@ -8,6 +8,9 @@ class MWTimestampTest extends MediaWikiLangTestCase { protected function setUp() { parent::setUp(); + // Avoid 'GetHumanTimestamp' hook and others + $this->setMwGlobals( 'wgHooks', array() ); + RequestContext::getMain()->setLanguage( Language::factory( 'en' ) ); } @@ -79,6 +82,17 @@ class MWTimestampTest extends MediaWikiLangTestCase { } /** + * 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 * @covers MWTimestamp::getTimestamp @@ -111,6 +125,18 @@ class MWTimestampTest extends MediaWikiLangTestCase { } /** + * 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 */ |