- * This mock user can only have isAllowed() called on it.
- *
- * @param array $groups Groups for the mock user to have
- * @return User
- */
- private function getMockUser( array $groups = [] ) : User {
- $groups[] = '*';
-
- $mock = $this->createMock( User::class );
- $mock->method( 'isAllowed' )->will( $this->returnCallback(
- function ( $action ) use ( $groups ) {
- global $wgGroupPermissions, $wgRevokePermissions;
- if ( $action == '' ) {
- return true;
- }
- foreach ( $wgRevokePermissions as $group => $rights ) {
- if ( !in_array( $group, $groups ) ) {
- continue;
- }
- if ( isset( $rights[$action] ) && $rights[$action] ) {
- return false;
- }
- }
- foreach ( $wgGroupPermissions as $group => $rights ) {
- if ( !in_array( $group, $groups ) ) {
- continue;
- }
- if ( isset( $rights[$action] ) && $rights[$action] ) {
- return true;
- }
- }
- return false;
- }
- ) );
- $mock->expects( $this->never() )->method( $this->anythingBut( 'isAllowed' ) );
- return $mock;
- }
-
- /**
+ * TODO: This is superceeded by PermissionManagerTest::testGetNamespaceRestrictionLevels
+ * Remove when deprecated method is removed.