From d2f782b22201c2a6b5bc8ba8b3223895cce1e88a Mon Sep 17 00:00:00 2001 From: MusikAnimal Date: Mon, 3 Jun 2019 15:52:46 -0400 Subject: [PATCH] Allow MediaWikiTestCase::editPage to use given User Sometimes you need to edit pages with a non-sysop. This is a follow-up to I9e48f7c00efbce8c2de3f5db3a74462d47ae8f64 Change-Id: I5a101638f57709c343a2e42ca0ae11527bee8cce --- tests/phpunit/MediaWikiTestCase.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 486b16de85..f9416bea2f 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -2380,13 +2380,20 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase { * @param string $text Content of the page * @param string $summary Optional summary string for the revision * @param int $defaultNs Optional namespace id + * @param User|null $user If null, static::getTestSysop()->getUser() is used. * @return Status Object as returned by WikiPage::doEditContent() * @throws MWException If this test cases's needsDB() method doesn't return true. * Test cases can use "@group Database" to enable database test support, * or list the tables under testing in $this->tablesUsed, or override the * needsDB() method. */ - protected function editPage( $pageName, $text, $summary = '', $defaultNs = NS_MAIN ) { + protected function editPage( + $pageName, + $text, + $summary = '', + $defaultNs = NS_MAIN, + User $user = null + ) { if ( !$this->needsDB() ) { throw new MWException( 'When testing which pages, the test cases\'s needsDB()' . ' method should return true. Use @group Database or $this->tablesUsed.' ); @@ -2395,7 +2402,13 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase { $title = Title::newFromText( $pageName, $defaultNs ); $page = WikiPage::factory( $title ); - return $page->doEditContent( ContentHandler::makeContent( $text, $title ), $summary ); + return $page->doEditContent( + ContentHandler::makeContent( $text, $title ), + $summary, + 0, + false, + $user + ); } /** -- 2.20.1