MediaWiki REL1_31
AvailableRightsTest.php
Go to the documentation of this file.
1<?php
2
9class AvailableRightsTest extends PHPUnit\Framework\TestCase {
10
11 use MediaWikiCoversValidator;
12
19 private function getAllVisibleRights() {
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(),
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
Permission keys revoked from users in each group.
$wgGroupPermissions['sysop']['replacetext']
Try to make sure that extensions register all rights in $wgAvailableRights or via the 'UserGetAllRigh...
getAllVisibleRights()
Returns all rights that should be in $wgAvailableRights + all rights registered via the 'UserGetAllRi...
static getAllRights()
Get a list of all available permissions.
Definition User.php:5111