Add test for RecentChange::isInRCLifespan
authoraddshore <addshorewiki@gmail.com>
Mon, 21 Sep 2015 09:34:13 +0000 (10:34 +0100)
committerAddshore <addshorewiki@gmail.com>
Mon, 21 Sep 2015 14:19:28 +0000 (14:19 +0000)
Change-Id: I0eac57d0cfabba3ed9b5b430e9972e7c5c0b9f8b

tests/phpunit/includes/changes/RecentChangeTest.php

index 9341c4c..0092ac2 100644 (file)
@@ -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 ) );
+       }
+
 }