Merge "SpecialWantedPages: Use Config instead of globals"
[lhc/web/wiklou.git] / tests / phpunit / includes / TitlePermissionTest.php
index c7cbc7b..988a4a4 100644 (file)
@@ -41,6 +41,9 @@ class TitlePermissionTest extends MediaWikiLangTestCase {
                                NS_MEDIAWIKI => 'editinterface',
                        ),
                ) );
+               // Without this testUserBlock will use a non-English context on non-English MediaWiki
+               // installations (because of how Title::checkUserBlock is implemented) and fail.
+               RequestContext::resetMain();
 
                $this->userName = 'Useruser';
                $this->altUserName = 'Altuseruser';
@@ -228,15 +231,21 @@ class TitlePermissionTest extends MediaWikiLangTestCase {
                $this->runGroupPermissions( 'move', array( array( 'movenotallowedfile' ) ) );
 
                $this->setUserPerm( "" );
-               $this->runGroupPermissions( 'move', array( array( 'movenotallowedfile' ), array( 'movenotallowed' ) ) );
+               $this->runGroupPermissions(
+                       'move',
+                       array( array( 'movenotallowedfile' ), array( 'movenotallowed' ) )
+               );
 
                $this->setUser( 'anon' );
                $this->setUserPerm( "move" );
                $this->runGroupPermissions( 'move', array( array( 'movenotallowedfile' ) ) );
 
                $this->setUserPerm( "" );
-               $this->runGroupPermissions( 'move', array( array( 'movenotallowedfile' ), array( 'movenotallowed' ) ),
-                       array( array( 'movenotallowedfile' ), array( 'movenologintext' ) ) );
+               $this->runGroupPermissions(
+                       'move',
+                       array( array( 'movenotallowedfile' ), array( 'movenotallowed' ) ),
+                       array( array( 'movenotallowedfile' ), array( 'movenologintext' ) )
+               );
 
                if ( $this->isWikitextNS( NS_MAIN ) ) {
                        //NOTE: some content models don't allow moving
@@ -293,13 +302,25 @@ class TitlePermissionTest extends MediaWikiLangTestCase {
                $this->assertEquals( array(), $res );
 
                $this->setUser( 'anon' );
-               $check = array( 'edit' => array( array( array( 'badaccess-groups', "*, [[$prefix:Users|Users]]", 2 ) ),
-                       array( array( 'badaccess-group0' ) ),
-                       array(), true ),
-                       'protect' => array( array( array( 'badaccess-groups', "[[$prefix:Administrators|Administrators]]", 1 ), array( 'protect-cantedit' ) ),
+               $check = array(
+                       'edit' => array(
+                               array( array( 'badaccess-groups', "*, [[$prefix:Users|Users]]", 2 ) ),
+                               array( array( 'badaccess-group0' ) ),
+                               array(),
+                               true
+                       ),
+                       'protect' => array(
+                               array( array(
+                                       'badaccess-groups',
+                                       "[[$prefix:Administrators|Administrators]]", 1 ),
+                                       array( 'protect-cantedit'
+                               ) ),
                                array( array( 'badaccess-group0' ), array( 'protect-cantedit' ) ),
-                               array( array( 'protect-cantedit' ) ), false ),
-                       '' => array( array(), array(), array(), true ) );
+                               array( array( 'protect-cantedit' ) ),
+                               false
+                       ),
+                       '' => array( array(), array(), array(), true )
+               );
 
                foreach ( array( "edit", "protect", "" ) as $action ) {
                        $this->setUserPerm( null );
@@ -599,8 +620,13 @@ class TitlePermissionTest extends MediaWikiLangTestCase {
                $this->setTitle( NS_MAIN, "test page" );
                $this->setUserPerm( array( "edit", "bogus" ) );
 
-               $this->title->mCascadeSources = array( Title::makeTitle( NS_MAIN, "Bogus" ), Title::makeTitle( NS_MAIN, "UnBogus" ) );
-               $this->title->mCascadingRestrictions = array( "bogus" => array( 'bogus', "sysop", "protect", "" ) );
+               $this->title->mCascadeSources = array(
+                       Title::makeTitle( NS_MAIN, "Bogus" ),
+                       Title::makeTitle( NS_MAIN, "UnBogus" )
+               );
+               $this->title->mCascadingRestrictions = array(
+                       "bogus" => array( 'bogus', "sysop", "protect", "" )
+               );
 
                $this->assertEquals( false,
                        $this->title->userCan( 'bogus', $this->user ) );