From 72566c80b1c0601341c63a00d470368601d65df5 Mon Sep 17 00:00:00 2001 From: MusikAnimal Date: Fri, 29 Jun 2018 15:56:22 -0400 Subject: [PATCH] Allow MediaWikiTestCase::insertPage to use given User Sometimes you need to create pages with a non-sysop. Example: I31aedcb9af7584fa5504916c67ca10f205ec9910 Change-Id: I9e48f7c00efbce8c2de3f5db3a74462d47ae8f64 --- tests/phpunit/MediaWikiTestCase.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 4140c23b14..f363d83a40 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -1075,12 +1075,14 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase { * @param string|Title $pageName Page name or title * @param string $text Page's content * @param int $namespace Namespace id (name cannot already contain namespace) + * @param User $user If null, static::getTestSysop()->getUser() is used. * @return array Title object and page id */ protected function insertPage( $pageName, $text = 'Sample page for unit test.', - $namespace = null + $namespace = null, + User $user = null ) { if ( is_string( $pageName ) ) { $title = Title::newFromText( $pageName, $namespace ); @@ -1088,7 +1090,9 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase { $title = $pageName; } - $user = static::getTestSysop()->getUser(); + if ( !$user ) { + $user = static::getTestSysop()->getUser(); + } $comment = __METHOD__ . ': Sample page for unit test.'; $page = WikiPage::factory( $title ); -- 2.20.1