Go to the documentation of this file.
14 $this->tablesUsed = array_merge(
16 [
'change_tag',
'change_tag_def',
'logging' ]
56 $expectedGroups = (
array)$expectedGroups;
57 $params[
'action'] =
'userrights';
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';
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' ]
202 [
'change_tag',
'logging' ],
205 'ct_log_id = log_id',
207 'log_title' => strtr(
$user->getName(),
' ',
'_' )
226 [
'change_tag',
'logging',
'change_tag_def' ],
229 'ct_log_id = log_id',
231 'log_title' => strtr(
$user->getName(),
' ',
'_' )
234 [
'change_tag_def' => [
'INNER JOIN',
'ctd_id = ct_tag_id' ] ]
245 'You do not have permission to apply change tags along with your changes.',
246 [
'tags' =>
'custom tag' ]
252 'There is no user by the name "Nonexistent user". Check your spelling.',
253 [
'user' =>
'Nonexistent user' ]
261 $token = $sysop->getEditToken(
$user->getName() );
264 'action' =>
'userrights',
265 'user' =>
$user->getName(),
270 $user->clearInstanceCache();
271 $this->assertSame( [
'sysop' ],
$user->getGroups() );
273 $this->assertArrayNotHasKey(
'warnings',
$res[0] );
288 $token = $sysop->getEditToken(
'userrights' );
291 'action' =>
'userrights',
292 'user' =>
$user->getName(),
298 ->setMethods( [
'canProcessExpiries' ] )
300 $mockUserRightsPage->method(
'canProcessExpiries' )->willReturn( $canProcessExpiries );
303 ->setConstructorArgs( [ $main,
'userrights' ] )
304 ->setMethods( [
'getUserRightsPage' ] )
306 $mockApi->method(
'getUserRightsPage' )->willReturn( $mockUserRightsPage );
313 $this->assertArrayHasKey(
'expiry', $mock1->getAllowedParams() );
316 $this->assertArrayNotHasKey(
'expiry', $mock2->getAllowedParams() );
329 array $permissions =
null,
array $groupsToChange,
array $expectedGroups
331 if ( $permissions !==
null ) {
336 'add' => implode(
'|', $groupsToChange[0] ),
337 'remove' => implode(
'|', $groupsToChange[1] ),
352 ],
'Add with only remove permission' => [
356 ],
'Add with global remove permission' => [
360 ],
'Simple remove' => [
364 ],
'Remove with only add permission' => [
368 ],
'Remove with global add permission' => [
372 ],
'Add and remove same new group' => [
374 [ [
'sysop' ], [
'sysop' ] ],
378 ],
'Add and remove same existing group' => [
380 [ [
'bot' ], [
'bot' ] ],
This is the main API class, used for both external and internal processing.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
WebRequest clone which takes values from a provided array.
testAddAndRemoveGroups(array $permissions=null, array $groupsToChange, array $expectedGroups)
Tests adding and removing various groups with various permissions.
doSuccessfulRightsChange( $expectedGroups='sysop', array $params=[], User $user=null)
Perform an API userrights request that's expected to be successful.
const MIGRATION_WRITE_BOTH
insert( $dbw=null)
Insert a block into the block table.
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
static isMutable(User $user)
doApiRequest(array $params, array $session=null, $appendModule=false, User $user=null, $tokenType=null)
Does the API request and returns the result.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
doApiRequestWithToken(array $params, array $session=null, User $user=null, $tokenType='auto')
Convenience function to access the token parameter of doApiRequest() more succinctly.
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))
testMultipleInvalidExpiries()
addAndRemoveGroupsProvider()
testBlockedWithoutUserrights()
setPermissions( $add=[], $remove=[])
Unsets $wgGroupPermissions['bureaucrat']['userrights'], and sets $wgAddGroups['bureaucrat'] and $wgRe...
doFailedRightsChange( $expectedException, array $params=[], User $user=null)
Perform an API userrights request that's expected to fail.
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
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
testBlockedWithUserrights()
testWithoutTagPermission()
getMockForProcessingExpiries( $canProcessExpiries)
Helper for testCanProcessExpiries that returns a mock ApiUserrights that either can or cannot process...