From: addshore Date: Mon, 21 Sep 2015 09:34:13 +0000 (+0100) Subject: Add test for RecentChange::isInRCLifespan X-Git-Tag: 1.31.0-rc.0~9939 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=9d144409b7869b5bcaca9dd15bae604b5096cc3d;p=lhc%2Fweb%2Fwiklou.git Add test for RecentChange::isInRCLifespan Change-Id: I0eac57d0cfabba3ed9b5b430e9972e7c5c0b9f8b --- 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 ) ); + } + }