14 $this->tablesUsed = array_merge(
16 [
'change_tag',
'change_tag_def',
'logging' ]
56 $expectedGroups = (
array)$expectedGroups;
57 $params[
'action'] =
'userrights';
63 $this->assertTrue( TestUserRegistry::isMutable(
$user ),
64 'Immutable user passed to doSuccessfulRightsChange!' );
75 $user->clearInstanceCache();
76 $this->assertSame( $expectedGroups,
$user->getGroups() );
78 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
93 $params[
'action'] =
'userrights';
95 $this->setExpectedException( ApiUsageException::class, $expectedException );
105 $this->assertTrue( TestUserRegistry::isMutable(
$user ),
106 'Immutable user passed to doFailedRightsChange!' );
114 $expectedGroups =
$user->getGroups();
119 $user->clearInstanceCache();
120 $this->assertSame( $expectedGroups,
$user->getGroups() );
131 $block =
new Block( [
'address' => $wgUser,
'by' => $wgUser->getId(), ] );
138 $wgUser->clearInstanceCache();
154 $user->clearInstanceCache();
160 [
'bureaucrat',
'sysop' ],
161 [
'add' =>
'bureaucrat|sysop' ]
167 '2 expiry timestamps were provided where 3 were needed.',
168 [
'add' =>
'sysop|bureaucrat|bot',
'expiry' =>
'infinity|tomorrow' ]
174 '3 expiry timestamps were provided where 2 were needed.',
175 [
'add' =>
'sysop|bureaucrat',
'expiry' =>
'infinity|tomorrow|never' ]
185 'Invalid expiry time "foo".',
186 [
'add' =>
'sysop|bureaucrat',
'expiry' =>
'foo|bar' ]
201 [
'change_tag',
'logging',
'change_tag_def' ],
204 'ct_log_id = log_id',
206 'log_title' => strtr(
$user->getName(),
' ',
'_' )
209 [
'change_tag_def' => [
'JOIN',
'ctd_id = ct_tag_id' ] ]
220 'You do not have permission to apply change tags along with your changes.',
221 [
'tags' =>
'custom tag' ]
227 'There is no user by the name "Nonexistent user". Check your spelling.',
228 [
'user' =>
'Nonexistent user' ]
236 $token = $sysop->getEditToken(
$user->getName() );
239 'action' =>
'userrights',
240 'user' =>
$user->getName(),
245 $user->clearInstanceCache();
246 $this->assertSame( [
'sysop' ],
$user->getGroups() );
248 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
263 $token = $sysop->getEditToken(
'userrights' );
266 'action' =>
'userrights',
267 'user' =>
$user->getName(),
272 $mockUserRightsPage = $this->getMockBuilder( UserrightsPage::class )
273 ->setMethods( [
'canProcessExpiries' ] )
275 $mockUserRightsPage->method(
'canProcessExpiries' )->willReturn( $canProcessExpiries );
277 $mockApi = $this->getMockBuilder( ApiUserrights::class )
278 ->setConstructorArgs( [ $main,
'userrights' ] )
279 ->setMethods( [
'getUserRightsPage' ] )
281 $mockApi->method(
'getUserRightsPage' )->willReturn( $mockUserRightsPage );
288 $this->assertArrayHasKey(
'expiry', $mock1->getAllowedParams() );
291 $this->assertArrayNotHasKey(
'expiry', $mock2->getAllowedParams() );
304 array $permissions =
null,
array $groupsToChange,
array $expectedGroups
306 if ( $permissions !==
null ) {
311 'add' => implode(
'|', $groupsToChange[0] ),
312 'remove' => implode(
'|', $groupsToChange[1] ),
327 ],
'Add with only remove permission' => [
331 ],
'Add with global remove permission' => [
335 ],
'Simple remove' => [
339 ],
'Remove with only add permission' => [
343 ],
'Remove with global add permission' => [
347 ],
'Add and remove same new group' => [
349 [ [
'sysop' ], [
'sysop' ] ],
353 ],
'Add and remove same existing group' => [
355 [ [
'bot' ], [
'bot' ] ],
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
This is the main API class, used for both external and internal processing.
doApiRequestWithToken(array $params, array $session=null, User $user=null, $tokenType='auto')
Convenience function to access the token parameter of doApiRequest() more succinctly.
doApiRequest(array $params, array $session=null, $appendModule=false, User $user=null, $tokenType=null)
Does the API request and returns the result.
testAddAndRemoveGroups(array $permissions=null, array $groupsToChange, array $expectedGroups)
Tests adding and removing various groups with various permissions.
doFailedRightsChange( $expectedException, array $params=[], User $user=null)
Perform an API userrights request that's expected to fail.
addAndRemoveGroupsProvider()
testBlockedWithUserrights()
doSuccessfulRightsChange( $expectedGroups='sysop', array $params=[], User $user=null)
Perform an API userrights request that's expected to be successful.
testMultipleInvalidExpiries()
setPermissions( $add=[], $remove=[])
Unsets $wgGroupPermissions['bureaucrat']['userrights'], and sets $wgAddGroups['bureaucrat'] and $wgRe...
testBlockedWithoutUserrights()
getMockForProcessingExpiries( $canProcessExpiries)
Helper for testCanProcessExpiries that returns a mock ApiUserrights that either can or cannot process...
testWithoutTagPermission()
WebRequest clone which takes values from a provided array.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
return true to allow those checks to and false if checking is done & $user
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))