Merge "Add checkDependencies.php"
[lhc/web/wiklou.git] / tests / phpunit / includes / auth / AuthManagerTest.php
index 5cf93c9..ea45b19 100644 (file)
@@ -3,6 +3,7 @@
 namespace MediaWiki\Auth;
 
 use Config;
+use MediaWiki\Block\DatabaseBlock;
 use MediaWiki\Session\SessionInfo;
 use MediaWiki\Session\UserInfo;
 use Psr\Log\LoggerInterface;
@@ -1419,6 +1420,7 @@ class AuthManagerTest extends \MediaWikiTestCase {
                $readOnlyMode->setReason( false );
 
                $this->setGroupPermissions( '*', 'createaccount', false );
+               $this->overrideMwServices();
                $status = $this->manager->checkAccountCreatePermissions( new \User );
                $this->assertFalse( $status->isOK() );
                $this->assertTrue( $status->hasMessage( 'badaccess-groups' ) );
@@ -1430,7 +1432,7 @@ class AuthManagerTest extends \MediaWikiTestCase {
                        \TestUser::setPasswordForUser( $user, 'UTBlockeePassword' );
                        $user->saveSettings();
                }
-               $oldBlock = \Block::newFromTarget( 'UTBlockee' );
+               $oldBlock = DatabaseBlock::newFromTarget( 'UTBlockee' );
                if ( $oldBlock ) {
                        // An old block will prevent our new one from saving.
                        $oldBlock->delete();
@@ -1443,8 +1445,9 @@ class AuthManagerTest extends \MediaWikiTestCase {
                        'expiry' => time() + 100500,
                        'createAccount' => true,
                ];
-               $block = new \Block( $blockOptions );
+               $block = new DatabaseBlock( $blockOptions );
                $block->insert();
+               $this->overrideMwServices();
                $status = $this->manager->checkAccountCreatePermissions( $user );
                $this->assertFalse( $status->isOK() );
                $this->assertTrue( $status->hasMessage( 'cantcreateaccount-text' ) );
@@ -1456,7 +1459,7 @@ class AuthManagerTest extends \MediaWikiTestCase {
                        'expiry' => time() + 100500,
                        'createAccount' => true,
                ];
-               $block = new \Block( $blockOptions );
+               $block = new DatabaseBlock( $blockOptions );
                $block->insert();
                $scopeVariable = new ScopedCallback( [ $block, 'delete' ] );
                $status = $this->manager->checkAccountCreatePermissions( new \User );
@@ -2364,6 +2367,8 @@ class AuthManagerTest extends \MediaWikiTestCase {
                $this->mergeMwGlobalArrayValue( 'wgObjectCaches',
                        [ __METHOD__ => [ 'class' => 'HashBagOStuff' ] ] );
                $this->setMwGlobals( [ 'wgMainCacheType' => __METHOD__ ] );
+               // Supply services with updated globals
+               $this->overrideMwServices();
 
                // Set up lots of mocks...
                $mocks = [];
@@ -2548,6 +2553,7 @@ class AuthManagerTest extends \MediaWikiTestCase {
                // IP unable to create accounts
                $this->setGroupPermissions( '*', 'createaccount', false );
                $this->setGroupPermissions( '*', 'autocreateaccount', false );
+               $this->overrideMwServices();
                $session->clear();
                $user = \User::newFromName( $username );
                $this->hook( 'LocalUserCreated', $this->never() );
@@ -2584,6 +2590,7 @@ class AuthManagerTest extends \MediaWikiTestCase {
                $session->clear();
                $user = \User::newFromName( $username );
                $this->hook( 'LocalUserCreated', $this->never() );
+               $this->overrideMwServices();
                $ret = $this->manager->autoCreateUser( $user, AuthManager::AUTOCREATE_SOURCE_SESSION, true );
                $this->unhook( 'LocalUserCreated' );
                $this->assertEquals( \Status::newFatal( 'ok' ), $ret );