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
This commit is contained in:
DannyS712 2020-01-29 02:58:30 +00:00
parent b010ac4019
commit 9f25a0b64e

View file

@ -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() {