From 9d144409b7869b5bcaca9dd15bae604b5096cc3d Mon Sep 17 00:00:00 2001 From: addshore Date: Mon, 21 Sep 2015 10:34:13 +0100 Subject: [PATCH] Add test for RecentChange::isInRCLifespan Change-Id: I0eac57d0cfabba3ed9b5b430e9972e7c5c0b9f8b --- .../includes/changes/RecentChangeTest.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/phpunit/includes/changes/RecentChangeTest.php b/tests/phpunit/includes/changes/RecentChangeTest.php index 9341c4c859..0092ac255b 100644 --- a/tests/phpunit/includes/changes/RecentChangeTest.php +++ b/tests/phpunit/includes/changes/RecentChangeTest.php @@ -104,4 +104,26 @@ class RecentChangeTest extends MediaWikiTestCase { $this->assertEquals( $expectedParseParams, $actualParseParams ); } + /** + * 50 mins and 100 mins are used here as the tests never take that long! + * @return array + */ + public function provideIsInRCLifespan() { + return array( + array( 6000, time() - 3000, 0, true ), + array( 3000, time() - 6000, 0, false ), + array( 6000, time() - 3000, 6000, true ), + array( 3000, time() - 6000, 6000, true ), + ); + } + + /** + * @covers RecentChange::isInRCLifespan + * @dataProvider provideIsInRCLifespan + */ + public function testIsInRCLifespan( $maxAge, $timestamp, $tolerance, $expected ) { + $this->setMwGlobals( 'wgRCMaxAge', $maxAge ); + $this->assertEquals( $expected, RecentChange::isInRCLifespan( $timestamp, $tolerance ) ); + } + } -- 2.20.1