$this->user = $this->userUser;
}
- $this->overrideMwServices();
- }
-
- protected function setUserPerm( $perm ) {
- // Setting member variables is evil!!!
-
- if ( is_array( $perm ) ) {
- $this->user->mRights = $perm;
- } else {
- $this->user->mRights = [ $perm ];
- }
+ $this->resetServices();
}
protected function setTitle( $ns, $title = "Main_Page" ) {
$this->setUser( 'anon' );
$this->setTitle( NS_TALK );
- $this->setUserPerm( "createtalk" );
+ $this->overrideUserPermissions( $this->user, "createtalk" );
$res = $this->title->getUserPermissionsErrors( 'create', $this->user );
$this->assertEquals( [], $res );
$this->setTitle( NS_TALK );
- $this->setUserPerm( "createpage" );
+ $this->overrideUserPermissions( $this->user, "createpage" );
$res = $this->title->getUserPermissionsErrors( 'create', $this->user );
$this->assertEquals( [ [ "nocreatetext" ] ], $res );
$this->setTitle( NS_TALK );
- $this->setUserPerm( "" );
+ $this->overrideUserPermissions( $this->user, "" );
$res = $this->title->getUserPermissionsErrors( 'create', $this->user );
$this->assertEquals( [ [ 'nocreatetext' ] ], $res );
$this->setTitle( NS_MAIN );
- $this->setUserPerm( "createpage" );
+ $this->overrideUserPermissions( $this->user, "createpage" );
$res = $this->title->getUserPermissionsErrors( 'create', $this->user );
$this->assertEquals( [], $res );
$this->setTitle( NS_MAIN );
- $this->setUserPerm( "createtalk" );
+ $this->overrideUserPermissions( $this->user, "createtalk" );
$res = $this->title->getUserPermissionsErrors( 'create', $this->user );
$this->assertEquals( [ [ 'nocreatetext' ] ], $res );
$this->setUser( $this->userName );
$this->setTitle( NS_TALK );
- $this->setUserPerm( "createtalk" );
+ $this->overrideUserPermissions( $this->user, "createtalk" );
$res = $this->title->getUserPermissionsErrors( 'create', $this->user );
$this->assertEquals( [], $res );
$this->setTitle( NS_TALK );
- $this->setUserPerm( "createpage" );
+ $this->overrideUserPermissions( $this->user, "createpage" );
$res = $this->title->getUserPermissionsErrors( 'create', $this->user );
$this->assertEquals( [ [ 'nocreate-loggedin' ] ], $res );
$this->setTitle( NS_TALK );
- $this->setUserPerm( "" );
+ $this->overrideUserPermissions( $this->user );
$res = $this->title->getUserPermissionsErrors( 'create', $this->user );
$this->assertEquals( [ [ 'nocreate-loggedin' ] ], $res );
$this->setTitle( NS_MAIN );
- $this->setUserPerm( "createpage" );
+ $this->overrideUserPermissions( $this->user, "createpage" );
$res = $this->title->getUserPermissionsErrors( 'create', $this->user );
$this->assertEquals( [], $res );
$this->setTitle( NS_MAIN );
- $this->setUserPerm( "createtalk" );
+ $this->overrideUserPermissions( $this->user, "createtalk" );
$res = $this->title->getUserPermissionsErrors( 'create', $this->user );
$this->assertEquals( [ [ 'nocreate-loggedin' ] ], $res );
$this->setTitle( NS_MAIN );
- $this->setUserPerm( "" );
+ $this->overrideUserPermissions( $this->user );
$res = $this->title->getUserPermissionsErrors( 'create', $this->user );
$this->assertEquals( [ [ 'nocreate-loggedin' ] ], $res );
$this->setUser( 'anon' );
$this->setTitle( NS_USER, $this->userName . '' );
- $this->setUserPerm( "" );
+ $this->overrideUserPermissions( $this->user );
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
$this->assertEquals( [ [ 'cant-move-user-page' ], [ 'movenologintext' ] ], $res );
$this->setTitle( NS_USER, $this->userName . '/subpage' );
- $this->setUserPerm( "" );
+ $this->overrideUserPermissions( $this->user );
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
$this->assertEquals( [ [ 'movenologintext' ] ], $res );
$this->setTitle( NS_USER, $this->userName . '' );
- $this->setUserPerm( "move-rootuserpages" );
+ $this->overrideUserPermissions( $this->user, "move-rootuserpages" );
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
$this->assertEquals( [ [ 'movenologintext' ] ], $res );
$this->setTitle( NS_USER, $this->userName . '/subpage' );
- $this->setUserPerm( "move-rootuserpages" );
+ $this->overrideUserPermissions( $this->user, "move-rootuserpages" );
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
$this->assertEquals( [ [ 'movenologintext' ] ], $res );
$this->setTitle( NS_USER, $this->userName . '' );
- $this->setUserPerm( "" );
+ $this->overrideUserPermissions( $this->user, "" );
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
$this->assertEquals( [ [ 'cant-move-user-page' ], [ 'movenologintext' ] ], $res );
$this->setTitle( NS_USER, $this->userName . '/subpage' );
- $this->setUserPerm( "" );
+ $this->overrideUserPermissions( $this->user, "" );
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
$this->assertEquals( [ [ 'movenologintext' ] ], $res );
$this->setTitle( NS_USER, $this->userName . '' );
- $this->setUserPerm( "move-rootuserpages" );
+ $this->overrideUserPermissions( $this->user, "move-rootuserpages" );
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
$this->assertEquals( [ [ 'movenologintext' ] ], $res );
$this->setTitle( NS_USER, $this->userName . '/subpage' );
- $this->setUserPerm( "move-rootuserpages" );
+ $this->overrideUserPermissions( $this->user, "move-rootuserpages" );
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
$this->assertEquals( [ [ 'movenologintext' ] ], $res );
$this->setUser( $this->userName );
$this->setTitle( NS_FILE, "img.png" );
- $this->setUserPerm( "" );
+ $this->overrideUserPermissions( $this->user );
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
$this->assertEquals( [ [ 'movenotallowedfile' ], [ 'movenotallowed' ] ], $res );
$this->setTitle( NS_FILE, "img.png" );
- $this->setUserPerm( "movefile" );
+ $this->overrideUserPermissions( $this->user, "movefile" );
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
$this->assertEquals( [ [ 'movenotallowed' ] ], $res );
$this->setUser( 'anon' );
$this->setTitle( NS_FILE, "img.png" );
- $this->setUserPerm( "" );
+ $this->overrideUserPermissions( $this->user );
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
$this->assertEquals( [ [ 'movenotallowedfile' ], [ 'movenologintext' ] ], $res );
$this->setTitle( NS_FILE, "img.png" );
- $this->setUserPerm( "movefile" );
+ $this->overrideUserPermissions( $this->user, "movefile" );
$res = $this->title->getUserPermissionsErrors( 'move', $this->user );
$this->assertEquals( [ [ 'movenologintext' ] ], $res );
$this->setUser( $this->userName );
- $this->setUserPerm( "move" );
+ $this->overrideUserPermissions( $this->user, "move" );
$this->runGroupPermissions( 'move', [ [ 'movenotallowedfile' ] ] );
- $this->setUserPerm( "" );
+ $this->overrideUserPermissions( $this->user );
$this->runGroupPermissions(
'move',
[ [ 'movenotallowedfile' ], [ 'movenotallowed' ] ]
);
$this->setUser( 'anon' );
- $this->setUserPerm( "move" );
+ $this->overrideUserPermissions( $this->user, "move" );
$this->runGroupPermissions( 'move', [ [ 'movenotallowedfile' ] ] );
- $this->setUserPerm( "" );
+ $this->overrideUserPermissions( $this->user );
$this->runGroupPermissions(
'move',
[ [ 'movenotallowedfile' ], [ 'movenotallowed' ] ],
$this->setTitle( NS_MAIN );
$this->setUser( 'anon' );
- $this->setUserPerm( "move" );
+ $this->overrideUserPermissions( $this->user, "move" );
$this->runGroupPermissions( 'move', [] );
- $this->setUserPerm( "" );
+ $this->overrideUserPermissions( $this->user, "" );
$this->runGroupPermissions( 'move', [ [ 'movenotallowed' ] ],
[ [ 'movenologintext' ] ] );
$this->setUser( $this->userName );
- $this->setUserPerm( "" );
+ $this->overrideUserPermissions( $this->user, "" );
$this->runGroupPermissions( 'move', [ [ 'movenotallowed' ] ] );
- $this->setUserPerm( "move" );
+ $this->overrideUserPermissions( $this->user, "move" );
$this->runGroupPermissions( 'move', [] );
$this->setUser( 'anon' );
- $this->setUserPerm( 'move' );
+ $this->overrideUserPermissions( $this->user, 'move' );
$res = $this->title->getUserPermissionsErrors( 'move-target', $this->user );
$this->assertEquals( [], $res );
- $this->setUserPerm( '' );
+ $this->overrideUserPermissions( $this->user );
$res = $this->title->getUserPermissionsErrors( 'move-target', $this->user );
$this->assertEquals( [ [ 'movenotallowed' ] ], $res );
}
$this->setTitle( NS_USER );
$this->setUser( $this->userName );
- $this->setUserPerm( [ "move", "move-rootuserpages" ] );
+ $this->overrideUserPermissions( $this->user, [ "move", "move-rootuserpages" ] );
$res = $this->title->getUserPermissionsErrors( 'move-target', $this->user );
$this->assertEquals( [], $res );
- $this->setUserPerm( "move" );
+ $this->overrideUserPermissions( $this->user, "move" );
$res = $this->title->getUserPermissionsErrors( 'move-target', $this->user );
$this->assertEquals( [ [ 'cant-move-to-user-page' ] ], $res );
$this->setUser( 'anon' );
- $this->setUserPerm( [ "move", "move-rootuserpages" ] );
+ $this->overrideUserPermissions( $this->user, [ "move", "move-rootuserpages" ] );
$res = $this->title->getUserPermissionsErrors( 'move-target', $this->user );
$this->assertEquals( [], $res );
$this->setTitle( NS_USER, "User/subpage" );
- $this->setUserPerm( [ "move", "move-rootuserpages" ] );
+ $this->overrideUserPermissions( $this->user, [ "move", "move-rootuserpages" ] );
$res = $this->title->getUserPermissionsErrors( 'move-target', $this->user );
$this->assertEquals( [], $res );
- $this->setUserPerm( "move" );
+ $this->overrideUserPermissions( $this->user, "move" );
$res = $this->title->getUserPermissionsErrors( 'move-target', $this->user );
$this->assertEquals( [], $res );
];
foreach ( [ "edit", "protect", "" ] as $action ) {
- $this->setUserPerm( null );
+ $this->overrideUserPermissions( $this->user );
$this->assertEquals( $check[$action][0],
$this->title->getUserPermissionsErrors( $action, $this->user, true ) );
$this->assertEquals( $check[$action][0],
$old = $wgGroupPermissions;
$wgGroupPermissions = [];
+ $this->resetServices();
+
$this->assertEquals( $check[$action][1],
$this->title->getUserPermissionsErrors( $action, $this->user, true ) );
$this->assertEquals( $check[$action][1],
$this->title->getUserPermissionsErrors( $action, $this->user, 'full' ) );
$this->assertEquals( $check[$action][1],
$this->title->getUserPermissionsErrors( $action, $this->user, 'secure' ) );
+
$wgGroupPermissions = $old;
+ $this->resetServices();
- $this->setUserPerm( $action );
+ $this->overrideUserPermissions( $this->user, $action );
$this->assertEquals( $check[$action][2],
$this->title->getUserPermissionsErrors( $action, $this->user, true ) );
$this->assertEquals( $check[$action][2],
$this->assertEquals( $check[$action][2],
$this->title->getUserPermissionsErrors( $action, $this->user, 'secure' ) );
- $this->setUserPerm( $action );
+ $this->overrideUserPermissions( $this->user, $action );
$this->assertEquals( $check[$action][3],
$this->title->userCan( $action, $this->user, true ) );
$this->assertEquals( $check[$action][3],
$result2 = $result;
}
+ // XXX: there could be a better way to handle this, but since we need to
+ // override PermissionManager service each time globals are changed
+ // and in the same time we need to keep user permissions overrides from the outside
+ // the best we can do inside this method is to save & restore faked user perms
+
+ $userPermsOverrides = MediaWikiServices::getInstance()->getPermissionManager()
+ ->getUserPermissions( $this->user );
+
$wgGroupPermissions['autoconfirmed']['move'] = false;
$wgGroupPermissions['user']['move'] = false;
+ $this->resetServices();
+ $this->overrideUserPermissions( $this->user, $userPermsOverrides );
$res = $this->title->getUserPermissionsErrors( $action, $this->user );
$this->assertEquals( $result, $res );
$wgGroupPermissions['autoconfirmed']['move'] = true;
$wgGroupPermissions['user']['move'] = false;
+ $this->resetServices();
+ $this->overrideUserPermissions( $this->user, $userPermsOverrides );
$res = $this->title->getUserPermissionsErrors( $action, $this->user );
$this->assertEquals( $result2, $res );
$wgGroupPermissions['autoconfirmed']['move'] = true;
$wgGroupPermissions['user']['move'] = true;
+ $this->resetServices();
+ $this->overrideUserPermissions( $this->user, $userPermsOverrides );
$res = $this->title->getUserPermissionsErrors( $action, $this->user );
$this->assertEquals( $result2, $res );
$wgGroupPermissions['autoconfirmed']['move'] = false;
$wgGroupPermissions['user']['move'] = true;
+ $this->resetServices();
+ $this->overrideUserPermissions( $this->user, $userPermsOverrides );
$res = $this->title->getUserPermissionsErrors( $action, $this->user );
$this->assertEquals( $result2, $res );
}
* @covers \MediaWiki\Permissions\PermissionManager::checkSpecialsAndNSPermissions
*/
public function testSpecialsAndNSPermissions() {
- global $wgNamespaceProtection;
$this->setUser( $this->userName );
$this->setTitle( NS_SPECIAL );
$this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
$this->setTitle( NS_MAIN );
- $this->setUserPerm( 'bogus' );
+ $this->overrideUserPermissions( $this->user, 'bogus' );
$this->assertEquals( [],
$this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
$this->setTitle( NS_MAIN );
- $this->setUserPerm( '' );
+ $this->overrideUserPermissions( $this->user );
$this->assertEquals( [ [ 'badaccess-group0' ] ],
$this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
- $wgNamespaceProtection[NS_USER] = [ 'bogus' ];
-
+ $this->mergeMwGlobalArrayValue( 'wgNamespaceProtection', [
+ NS_USER => [ 'bogus' ]
+ ] );
+ $this->resetServices();
$this->setTitle( NS_USER );
- $this->setUserPerm( '' );
+ $this->overrideUserPermissions( $this->user );
$this->assertEquals( [ [ 'badaccess-group0' ],
[ 'namespaceprotected', 'User', 'bogus' ] ],
$this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
$this->setTitle( NS_MEDIAWIKI );
- $this->setUserPerm( 'bogus' );
+ $this->overrideUserPermissions( $this->user, 'bogus' );
$this->assertEquals( [ [ 'protectedinterface', 'bogus' ] ],
$this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
$this->setTitle( NS_MEDIAWIKI );
- $this->setUserPerm( 'bogus' );
+ $this->overrideUserPermissions( $this->user, 'bogus' );
$this->assertEquals( [ [ 'protectedinterface', 'bogus' ] ],
$this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
- $wgNamespaceProtection = null;
-
- $this->setUserPerm( 'bogus' );
+ $this->setMwGlobals( 'wgNamespaceProtection', null );
+ $this->resetServices();
+ $this->overrideUserPermissions( $this->user, 'bogus' );
$this->assertEquals( [],
$this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
$this->assertEquals( true,
$this->title->userCan( 'bogus', $this->user ) );
- $this->setUserPerm( '' );
+ $this->overrideUserPermissions( $this->user );
$this->assertEquals( [ [ 'badaccess-group0' ] ],
$this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
$this->assertEquals( false,
$resultUserJs,
$resultPatrol
) {
- $this->setUserPerm( '' );
+ $this->overrideUserPermissions( $this->user );
$result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
$this->assertEquals( $resultNone, $result );
- $this->setUserPerm( 'editmyusercss' );
+ $this->overrideUserPermissions( $this->user, 'editmyusercss' );
$result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
$this->assertEquals( $resultMyCss, $result );
- $this->setUserPerm( 'editmyuserjson' );
+ $this->overrideUserPermissions( $this->user, 'editmyuserjson' );
$result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
$this->assertEquals( $resultMyJson, $result );
- $this->setUserPerm( 'editmyuserjs' );
+ $this->overrideUserPermissions( $this->user, 'editmyuserjs' );
$result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
$this->assertEquals( $resultMyJs, $result );
- $this->setUserPerm( 'editusercss' );
+ $this->overrideUserPermissions( $this->user, 'editusercss' );
$result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
$this->assertEquals( $resultUserCss, $result );
- $this->setUserPerm( 'edituserjson' );
+ $this->overrideUserPermissions( $this->user, 'edituserjson' );
$result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
$this->assertEquals( $resultUserJson, $result );
- $this->setUserPerm( 'edituserjs' );
+ $this->overrideUserPermissions( $this->user, 'edituserjs' );
$result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
$this->assertEquals( $resultUserJs, $result );
- $this->setUserPerm( '' );
+ $this->overrideUserPermissions( $this->user );
$result = $this->title->getUserPermissionsErrors( 'patrol', $this->user );
$this->assertEquals( reset( $resultPatrol[0] ), reset( $result[0] ) );
- $this->setUserPerm( [ 'edituserjs', 'edituserjson', 'editusercss' ] );
+ $this->overrideUserPermissions( $this->user, [ 'edituserjs', 'edituserjson', 'editusercss' ] );
$result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
$this->assertEquals( [ [ 'badaccess-group0' ] ], $result );
}
$this->setTitle( NS_MAIN );
$this->title->mRestrictionsLoaded = true;
- $this->setUserPerm( "edit" );
+ $this->overrideUserPermissions( $this->user, "edit" );
$this->title->mRestrictions = [ "bogus" => [ 'bogus', "sysop", "protect", "" ] ];
$this->assertEquals( [],
[ 'protectedpagetext', 'protect', 'edit' ] ],
$this->title->getUserPermissionsErrors( 'edit',
$this->user ) );
- $this->setUserPerm( "" );
+ $this->overrideUserPermissions( $this->user );
$this->assertEquals( [ [ 'badaccess-group0' ],
[ 'protectedpagetext', 'bogus', 'bogus' ],
[ 'protectedpagetext', 'editprotected', 'bogus' ],
[ 'protectedpagetext', 'protect', 'edit' ] ],
$this->title->getUserPermissionsErrors( 'edit',
$this->user ) );
- $this->setUserPerm( [ "edit", "editprotected" ] );
+ $this->overrideUserPermissions( $this->user, [ "edit", "editprotected" ] );
$this->assertEquals( [ [ 'badaccess-group0' ],
[ 'protectedpagetext', 'bogus', 'bogus' ],
[ 'protectedpagetext', 'protect', 'bogus' ] ],
$this->user ) );
$this->title->mCascadeRestriction = true;
- $this->setUserPerm( "edit" );
+ $this->overrideUserPermissions( $this->user, "edit" );
$this->assertEquals( false,
$this->title->quickUserCan( 'bogus', $this->user ) );
$this->assertEquals( false,
$this->title->getUserPermissionsErrors( 'edit',
$this->user ) );
- $this->setUserPerm( [ "edit", "editprotected" ] );
+ $this->overrideUserPermissions( $this->user, [ "edit", "editprotected" ] );
$this->assertEquals( false,
$this->title->quickUserCan( 'bogus', $this->user ) );
$this->assertEquals( false,
*/
public function testCascadingSourcesRestrictions() {
$this->setTitle( NS_MAIN, "test page" );
- $this->setUserPerm( [ "edit", "bogus" ] );
+ $this->overrideUserPermissions( $this->user, [ "edit", "bogus" ] );
$this->title->mCascadeSources = [
Title::makeTitle( NS_MAIN, "Bogus" ),
* @covers \MediaWiki\Permissions\PermissionManager::checkActionPermissions
*/
public function testActionPermissions() {
- $this->setUserPerm( [ "createpage" ] );
+ $this->overrideUserPermissions( $this->user, [ "createpage" ] );
$this->setTitle( NS_MAIN, "test page" );
$this->title->mTitleProtection['permission'] = '';
$this->title->mTitleProtection['user'] = $this->user->getId();
$this->title->userCan( 'create', $this->user ) );
$this->title->mTitleProtection['permission'] = 'editprotected';
- $this->setUserPerm( [ 'createpage', 'protect' ] );
+ $this->overrideUserPermissions( $this->user, [ 'createpage', 'protect' ] );
$this->assertEquals( [ [ 'titleprotected', 'Useruser', 'test' ] ],
$this->title->getUserPermissionsErrors( 'create', $this->user ) );
$this->assertEquals( false,
$this->title->userCan( 'create', $this->user ) );
- $this->setUserPerm( [ 'createpage', 'editprotected' ] );
+ $this->overrideUserPermissions( $this->user, [ 'createpage', 'editprotected' ] );
$this->assertEquals( [],
$this->title->getUserPermissionsErrors( 'create', $this->user ) );
$this->assertEquals( true,
$this->title->userCan( 'create', $this->user ) );
- $this->setUserPerm( [ 'createpage' ] );
+ $this->overrideUserPermissions( $this->user, [ 'createpage' ] );
$this->assertEquals( [ [ 'titleprotected', 'Useruser', 'test' ] ],
$this->title->getUserPermissionsErrors( 'create', $this->user ) );
$this->assertEquals( false,
$this->title->userCan( 'create', $this->user ) );
$this->setTitle( NS_MEDIA, "test page" );
- $this->setUserPerm( [ "move" ] );
+ $this->overrideUserPermissions( $this->user, [ "move" ] );
$this->assertEquals( false,
$this->title->userCan( 'move', $this->user ) );
$this->assertEquals( [ [ 'immobile-source-namespace', 'Media' ] ],
'wgEmailAuthentication' => true,
'wgBlockDisablesLogin' => false,
] );
- $this->overrideMwServices();
+ $this->resetServices();
- $this->setUserPerm( [ 'createpage', 'edit', 'move', 'rollback', 'patrol', 'upload', 'purge' ] );
+ $this->overrideUserPermissions(
+ $this->user,
+ [ 'createpage', 'edit', 'move', 'rollback', 'patrol', 'upload', 'purge' ]
+ );
$this->setTitle( NS_HELP, "test page" );
# $wgEmailConfirmToEdit only applies to 'edit' action
$this->title->getUserPermissionsErrors( 'edit', $this->user ) );
$this->setMwGlobals( 'wgEmailConfirmToEdit', false );
- $this->overrideMwServices();
+ $this->resetServices();
+ $this->overrideUserPermissions(
+ $this->user,
+ [ 'createpage', 'edit', 'move', 'rollback', 'patrol', 'upload', 'purge' ]
+ );
$this->assertNotContains( [ 'confirmedittext' ],
$this->title->getUserPermissionsErrors( 'edit', $this->user ) );
'address' => '127.0.8.1',
'by' => $this->user->getId(),
'reason' => 'no reason given',
- 'timestamp' => $prev + 3600,
+ 'timestamp' => $prev,
'auto' => true,
'expiry' => 0
] );
- $this->user->mBlock->setTimestamp( 0 );
$this->assertEquals( [ [ 'autoblockedtext',
- '[[User:Useruser|Useruser]]', 'no reason given', '127.0.0.1',
- 'Useruser', null, 'infinite', '127.0.8.1',
+ "[[User:Useruser|\u{202A}Useruser\u{202C}]]", 'no reason given', '127.0.0.1',
+ "\u{202A}Useruser\u{202C}", null, 'infinite', '127.0.8.1',
$wgLang->timeanddate( wfTimestamp( TS_MW, $prev ), true ) ] ],
$this->title->getUserPermissionsErrors( 'move-target',
$this->user ) );
'expiry' => 10,
] );
$this->assertEquals( [ [ 'blockedtext',
- '[[User:Useruser|Useruser]]', 'no reason given', '127.0.0.1',
- 'Useruser', null, '23:00, 31 December 1969', '127.0.8.1',
+ "[[User:Useruser|\u{202A}Useruser\u{202C}]]", 'no reason given', '127.0.0.1',
+ "\u{202A}Useruser\u{202C}", null, '23:00, 31 December 1969', '127.0.8.1',
$wgLang->timeanddate( wfTimestamp( TS_MW, $now ), true ) ] ],
$this->title->getUserPermissionsErrors( 'move-target', $this->user ) );
# $action != 'read' && $action != 'createaccount' && $user->isBlockedFrom( $this )
] );
$errors = [ [ 'systemblockedtext',
- '[[User:Useruser|Useruser]]', 'no reason given', '127.0.0.1',
- 'Useruser', 'test', 'infinite', '127.0.8.1',
+ "[[User:Useruser|\u{202A}Useruser\u{202C}]]", 'no reason given', '127.0.0.1',
+ "\u{202A}Useruser\u{202C}", 'test', 'infinite', '127.0.8.1',
$wgLang->timeanddate( wfTimestamp( TS_MW, $now ), true ) ] ];
$this->assertEquals( $errors,
] );
$errors = [ [ 'blockedtext-partial',
- '[[User:Useruser|Useruser]]', 'no reason given', '127.0.0.1',
- 'Useruser', null, '23:00, 31 December 1969', '127.0.8.1',
+ "[[User:Useruser|\u{202A}Useruser\u{202C}]]", 'no reason given', '127.0.0.1',
+ "\u{202A}Useruser\u{202C}", null, '23:00, 31 December 1969', '127.0.8.1',
$wgLang->timeanddate( wfTimestamp( TS_MW, $now ), true ) ] ];
$this->assertEquals( $errors,
],
],
] );
+ $this->resetServices();
$now = time();
$this->user->mBlockedby = $this->user->getName();
] );
$errors = [ [ 'blockedtext',
- '[[User:Useruser|Useruser]]', 'no reason given', '127.0.0.1',
- 'Useruser', null, 'infinite', '127.0.8.1',
+ "[[User:Useruser|\u{202A}Useruser\u{202C}]]", 'no reason given', '127.0.0.1',
+ "\u{202A}Useruser\u{202C}", null, 'infinite', '127.0.8.1',
$wgLang->timeanddate( wfTimestamp( TS_MW, $now ), true ) ] ];
$this->assertEquals( $errors,