From f6d65e533c62f6deb21342d4901ece24497b433e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 4 Jun 2015 07:31:04 +0200 Subject: Update to MediaWiki 1.25.1 --- tests/phpunit/structure/AvailableRightsTest.php | 51 +++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tests/phpunit/structure/AvailableRightsTest.php (limited to 'tests/phpunit/structure/AvailableRightsTest.php') diff --git a/tests/phpunit/structure/AvailableRightsTest.php b/tests/phpunit/structure/AvailableRightsTest.php new file mode 100644 index 00000000..51d31aaa --- /dev/null +++ b/tests/phpunit/structure/AvailableRightsTest.php @@ -0,0 +1,51 @@ + + */ +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' + ); + } +} -- cgit v1.2.2