X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fchanges%2FRecentChangeTest.php;h=68f907958fd052f3294348a1a9e9bf24c5e841ed;hb=8269ed4dfd5e4395e25945b1fa2ed391684606ed;hp=2efc802cdab5ed5024da6df7bf32b8b770fb9784;hpb=77579c6f1037daf2a053cab7ee51280f962f2e36;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/changes/RecentChangeTest.php b/tests/phpunit/includes/changes/RecentChangeTest.php index 2efc802cda..333eb28610 100644 --- a/tests/phpunit/includes/changes/RecentChangeTest.php +++ b/tests/phpunit/includes/changes/RecentChangeTest.php @@ -1,4 +1,5 @@ getTestUser()->getUser(); + $actorId = $user->getActorId(); + + $row = new stdClass(); + $row->rc_foo = 'AAA'; + $row->rc_timestamp = '20150921134808'; + $row->rc_deleted = 'bar'; + $row->rc_comment_text = 'comment'; + $row->rc_comment_data = null; + $row->rc_user = $user->getId(); + + $rc = RecentChange::newFromRow( $row ); + + $expected = [ + 'rc_foo' => 'AAA', + 'rc_timestamp' => '20150921134808', + 'rc_deleted' => 'bar', + 'rc_comment' => 'comment', + 'rc_comment_text' => 'comment', + 'rc_comment_data' => null, + 'rc_user' => $user->getId(), + 'rc_user_text' => $user->getName(), + 'rc_actor' => $actorId, + ]; + $this->assertEquals( $expected, $rc->getAttributes() ); + $row = new stdClass(); $row->rc_foo = 'AAA'; $row->rc_timestamp = '20150921134808'; $row->rc_deleted = 'bar'; + $row->rc_comment = 'comment'; + $row->rc_user = $user->getId(); + Wikimedia\suppressWarnings(); $rc = RecentChange::newFromRow( $row ); + Wikimedia\restoreWarnings(); $expected = [ 'rc_foo' => 'AAA', 'rc_timestamp' => '20150921134808', 'rc_deleted' => 'bar', + 'rc_comment' => 'comment', + 'rc_comment_text' => 'comment', + 'rc_comment_data' => null, + 'rc_user' => $user->getId(), + 'rc_user_text' => $user->getName(), + 'rc_actor' => $actorId, ]; $this->assertEquals( $expected, $rc->getAttributes() ); } @@ -87,15 +124,14 @@ class RecentChangeTest extends MediaWikiTestCase { } /** - * 50 mins and 100 mins are used here as the tests never take that long! * @return array */ public function provideIsInRCLifespan() { return [ - [ 6000, time() - 3000, 0, true ], - [ 3000, time() - 6000, 0, false ], - [ 6000, time() - 3000, 6000, true ], - [ 3000, time() - 6000, 6000, true ], + [ 6000, -3000, 0, true ], + [ 3000, -6000, 0, false ], + [ 6000, -3000, 6000, true ], + [ 3000, -6000, 6000, true ], ]; } @@ -103,8 +139,12 @@ class RecentChangeTest extends MediaWikiTestCase { * @covers RecentChange::isInRCLifespan * @dataProvider provideIsInRCLifespan */ - public function testIsInRCLifespan( $maxAge, $timestamp, $tolerance, $expected ) { + public function testIsInRCLifespan( $maxAge, $offset, $tolerance, $expected ) { $this->setMwGlobals( 'wgRCMaxAge', $maxAge ); + // Calculate this here instead of the data provider because the provider + // is expanded early on and the full test suite may take longer than 100 minutes + // when coverage is enabled. + $timestamp = time() + $offset; $this->assertEquals( $expected, RecentChange::isInRCLifespan( $timestamp, $tolerance ) ); } @@ -161,7 +201,7 @@ class RecentChangeTest extends MediaWikiTestCase { $pageProps->expects( $this->once() ) ->method( 'getProperties' ) ->with( $categoryTitle, 'hiddencat' ) - ->will( $this->returnValue( $isHidden ? [ $categoryTitle->getArticleID() => '' ] : [ ] ) ); + ->will( $this->returnValue( $isHidden ? [ $categoryTitle->getArticleID() => '' ] : [] ) ); $scopedOverride = PageProps::overrideInstance( $pageProps );