From 0d51852087a7a823ae0dcab961a0c86d67caa4a6 Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 29 Jun 2018 11:59:51 +0200 Subject: [PATCH] Regression test for autopatrolling rollbacks Bug: T198449 Change-Id: Ic280c38ac2ba0a0842c484f671e7e99f50cd54d5 --- .../includes/page/WikiPageDbTestBase.php | 66 +++++-------------- 1 file changed, 15 insertions(+), 51 deletions(-) diff --git a/tests/phpunit/includes/page/WikiPageDbTestBase.php b/tests/phpunit/includes/page/WikiPageDbTestBase.php index 63cf02f1e4..e0364c4c91 100644 --- a/tests/phpunit/includes/page/WikiPageDbTestBase.php +++ b/tests/phpunit/includes/page/WikiPageDbTestBase.php @@ -1,5 +1,6 @@ getTestUser( [ 'confirmed' ] )->getUser(); + // make sure we can test autopatrolling + $this->setMwGlobals( 'wgUseRCPatrol', true ); + // TODO: MCR: test rollback of multiple slots! $page = $this->newPage( __METHOD__ ); @@ -1085,61 +1089,21 @@ more stuff "rollback did not revert to the correct revision" ); $this->assertEquals( "one\n\ntwo", $page->getContent()->getNativeData() ); - // TODO: MCR: assert origin once we write slot data - // $mainSlot = $page->getRevision()->getRevisionRecord()->getSlot( 'main' ); - // $this->assertTrue( $mainSlot->isInherited(), 'isInherited' ); - // $this->assertSame( $rev2->getId(), $mainSlot->getOrigin(), 'getOrigin' ); - } - - /** - * @covers WikiPage::doRollback - * @covers WikiPage::commitRollback - */ - public function testDoRollback_simple() { - $admin = $this->getTestSysop()->getUser(); - - $text = "one"; - $page = $this->newPage( __METHOD__ ); - $page->doEditContent( - ContentHandler::makeContent( $text, $page->getTitle(), CONTENT_MODEL_WIKITEXT ), - "section one", - EDIT_NEW, - false, - $admin - ); - $rev1 = $page->getRevision(); - - $user1 = $this->getTestUser()->getUser(); - $text .= "\n\ntwo"; - $page = new WikiPage( $page->getTitle() ); - $page->doEditContent( - ContentHandler::makeContent( $text, $page->getTitle(), CONTENT_MODEL_WIKITEXT ), - "adding section two", - 0, - false, - $user1 + $rc = MediaWikiServices::getInstance()->getRevisionStore()->getRecentChange( + $page->getRevision()->getRevisionRecord() ); - # now, try the rollback - $token = $admin->getEditToken( 'rollback' ); - $errors = $page->doRollback( - $user1->getName(), - "testing revert", - $token, - false, - $details, - $admin + $this->assertNotNull( $rc, 'RecentChanges entry' ); + $this->assertEquals( + RecentChange::PRC_AUTOPATROLLED, + $rc->getAttribute( 'rc_patrolled' ), + 'rc_patrolled' ); - if ( $errors ) { - $this->fail( "Rollback failed:\n" . print_r( $errors, true ) - . ";\n" . print_r( $details, true ) ); - } - - $page = new WikiPage( $page->getTitle() ); - $this->assertEquals( $rev1->getSha1(), $page->getRevision()->getSha1(), - "rollback did not revert to the correct revision" ); - $this->assertEquals( "one", $page->getContent()->getNativeData() ); + // TODO: MCR: assert origin once we write slot data + // $mainSlot = $page->getRevision()->getRevisionRecord()->getSlot( 'main' ); + // $this->assertTrue( $mainSlot->isInherited(), 'isInherited' ); + // $this->assertSame( $rev2->getId(), $mainSlot->getOrigin(), 'getOrigin' ); } /** -- 2.20.1