From 9f25a0b64e382e50ccd08b3e326a74847c908ffc Mon Sep 17 00:00:00 2001 From: DannyS712 Date: Wed, 29 Jan 2020 02:58:30 +0000 Subject: [PATCH] Remove use of global $wgUser Reword ApiCoreThankIntegrationTest::testLogThanksForADeletedLogEntry to avoid needing to use it Also remove one use of doLogin(), remaining will be removed separately Bug: T243874 Bug: T244039 Change-Id: I6cf26839cb4e3042408fb6b059fb877b605763e8 --- tests/phpunit/ApiCoreThankIntegrationTest.php | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/phpunit/ApiCoreThankIntegrationTest.php b/tests/phpunit/ApiCoreThankIntegrationTest.php index 3fa7a6af..138ad0c0 100644 --- a/tests/phpunit/ApiCoreThankIntegrationTest.php +++ b/tests/phpunit/ApiCoreThankIntegrationTest.php @@ -95,21 +95,25 @@ class ApiCoreThankIntegrationTest extends ApiTestCase { } public function testLogThanksForADeletedLogEntry() { - global $wgUser; + $this->mergeMwGlobalArrayValue( 'wgGroupPermissions', [ + 'logdeleter' => [ + 'read' => true, + 'writeapi' => true, + 'deletelogentry' => true + ] + ] ); // Mark our test log entry as deleted. - // To do this we briefly switch back to our 'uploader' test user. - $this->doLogin( 'uploader' ); - // XXX: mRights[] = .. will lead to issues due __set magic in User - $wgUser->mRights = [ 'read', 'writeapi', 'deletelogentry' ]; + // To do this we briefly switch to a different test user. + $logdeleter = $this->getTestUser( [ 'logdeleter' ] )->getUser(); $this->doApiRequestWithToken( [ 'action' => 'revisiondelete', 'type' => 'logging', 'ids' => $this->logId, 'hide' => 'content', - ] ); - $this->doLogin( 'sysop' ); + ], null, $logdeleter ); + $sysop = $this->getTestSysop()->getUser(); // Then try to thank for it, and we should get an exception. $this->expectException( ApiUsageException::class ); $this->expectExceptionMessage( @@ -117,7 +121,7 @@ class ApiCoreThankIntegrationTest extends ApiTestCase { $this->doApiRequestWithToken( [ 'action' => 'thank', 'log' => $this->logId, - ] ); + ], null, $sysop ); } public function testValidRequestWithSource() {