- Removed space after casts - Removed spaces in array index - Added spaces around string concat - Added space after words: switch, foreach - else if -> elseif - Removed parentheses around require_once, because it is not a function - Added newline at end of file - Removed double spaces - Added spaces around operations - Removed repeated newlines Bug: T102609 Change-Id: Ib860222b24f8ad8e9062cd4dc42ec88dc63fb49e
51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Try to make sure that extensions register all rights in $wgAvailableRights
|
|
* or via the 'UserGetAllRights' hook.
|
|
*
|
|
* @author Marius Hoch < hoo@online.de >
|
|
*/
|
|
class AvailableRightsTest extends PHPUnit_Framework_TestCase {
|
|
|
|
/**
|
|
* Returns all rights that should be in $wgAvailableRights + all rights
|
|
* registered via the 'UserGetAllRights' hook + all "core" rights.
|
|
*
|
|
* @return string[]
|
|
*/
|
|
private function getAllVisibleRights() {
|
|
global $wgGroupPermissions, $wgRevokePermissions;
|
|
|
|
$rights = User::getAllRights();
|
|
|
|
foreach ( $wgGroupPermissions as $permissions ) {
|
|
$rights = array_merge( $rights, array_keys( $permissions ) );
|
|
}
|
|
|
|
foreach ( $wgRevokePermissions as $permissions ) {
|
|
$rights = array_merge( $rights, array_keys( $permissions ) );
|
|
}
|
|
|
|
$rights = array_unique( $rights );
|
|
sort( $rights );
|
|
|
|
return $rights;
|
|
}
|
|
|
|
public function testAvailableRights() {
|
|
$missingRights = array_diff(
|
|
$this->getAllVisibleRights(),
|
|
User::getAllRights()
|
|
);
|
|
|
|
$this->assertEquals(
|
|
array(),
|
|
// Re-index to produce nicer output, keys are meaningless.
|
|
array_values( $missingRights ),
|
|
'Additional user rights need to be added to $wgAvailableRights or ' .
|
|
'via the "UserGetAllRights" hook. See the instructions at: ' .
|
|
'https://www.mediawiki.org/wiki/Manual:User_rights#Adding_new_rights'
|
|
);
|
|
}
|
|
}
|