MediaWiki
REL1_31
AvailableRightsTest.php
Go to the documentation of this file.
1
<?php
2
9
class
AvailableRightsTest
extends
PHPUnit\Framework\TestCase {
10
11
use MediaWikiCoversValidator;
12
19
private
function
getAllVisibleRights
() {
20
global
$wgGroupPermissions
,
$wgRevokePermissions
;
21
22
$rights =
User::getAllRights
();
23
24
foreach
(
$wgGroupPermissions
as $permissions ) {
25
$rights = array_merge( $rights, array_keys( $permissions ) );
26
}
27
28
foreach
(
$wgRevokePermissions
as $permissions ) {
29
$rights = array_merge( $rights, array_keys( $permissions ) );
30
}
31
32
$rights = array_unique( $rights );
33
sort( $rights );
34
35
return
$rights;
36
}
37
38
public
function
testAvailableRights
() {
39
$missingRights = array_diff(
40
$this->
getAllVisibleRights
(),
41
User::getAllRights
()
42
);
43
44
$this->assertEquals(
45
[],
46
// Re-index to produce nicer output, keys are meaningless.
47
array_values( $missingRights ),
48
'Additional user rights need to be added to $wgAvailableRights or '
.
49
'via the "UserGetAllRights" hook. See the instructions at: '
.
50
'https://www.mediawiki.org/wiki/Manual:User_rights#Adding_new_rights'
51
);
52
}
53
}
$wgRevokePermissions
$wgRevokePermissions
Permission keys revoked from users in each group.
Definition
DefaultSettings.php:5264
$wgGroupPermissions
$wgGroupPermissions['sysop']['replacetext']
Definition
ReplaceText.php:56
AvailableRightsTest
Try to make sure that extensions register all rights in $wgAvailableRights or via the 'UserGetAllRigh...
Definition
AvailableRightsTest.php:9
AvailableRightsTest\getAllVisibleRights
getAllVisibleRights()
Returns all rights that should be in $wgAvailableRights + all rights registered via the 'UserGetAllRi...
Definition
AvailableRightsTest.php:19
AvailableRightsTest\testAvailableRights
testAvailableRights()
Definition
AvailableRightsTest.php:38
User\getAllRights
static getAllRights()
Get a list of all available permissions.
Definition
User.php:5111
tests
phpunit
structure
AvailableRightsTest.php
Generated on Mon Nov 25 2024 15:36:44 for MediaWiki by
1.10.0