From 76ff299d8c2adf6258849202acd6ef5679238d11 Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Sat, 4 Apr 2020 16:57:51 +0200 Subject: [PATCH] Use MediaWikiServices::getAuthManager This required MediaWiki 1.35 (already set in extension.json) Change-Id: Ic640f25b299dd7be429766f028ec91ab9481c85c --- .../CaptchaPreAuthenticationProviderTest.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/CaptchaPreAuthenticationProviderTest.php b/tests/phpunit/CaptchaPreAuthenticationProviderTest.php index 0df99d1af..763c78f10 100644 --- a/tests/phpunit/CaptchaPreAuthenticationProviderTest.php +++ b/tests/phpunit/CaptchaPreAuthenticationProviderTest.php @@ -2,6 +2,7 @@ use MediaWiki\Auth\AuthManager; use MediaWiki\Auth\UsernameAuthenticationRequest; +use MediaWiki\MediaWikiServices; use Wikimedia\TestingAccessWrapper; /** @@ -50,7 +51,7 @@ class CaptchaPreAuthenticationProviderTest extends MediaWikiTestCase { $request->setCookie( 'UserName', $username ); $provider = new CaptchaPreAuthenticationProvider(); - $provider->setManager( AuthManager::singleton() ); + $provider->setManager( MediaWikiServices::getInstance()->getAuthManager() ); $reqs = $provider->getAuthenticationRequests( $action, [ 'username' => $username ] ); if ( $needsCaptcha ) { $this->assertCount( 1, $reqs ); @@ -82,7 +83,7 @@ class CaptchaPreAuthenticationProviderTest extends MediaWikiTestCase { $this->setTriggers( [ 'createaccount' ] ); $captcha = new SimpleCaptcha(); $provider = new CaptchaPreAuthenticationProvider(); - $provider->setManager( AuthManager::singleton() ); + $provider->setManager( MediaWikiServices::getInstance()->getAuthManager() ); $reqs = $provider->getAuthenticationRequests( AuthManager::ACTION_CREATE, [ 'username' => 'Foo' ] ); @@ -116,7 +117,7 @@ class CaptchaPreAuthenticationProviderTest extends MediaWikiTestCase { $this->setMwGlobals( 'wgCaptcha', $captcha ); TestingAccessWrapper::newFromClass( ConfirmEditHooks::class )->instanceCreated = true; $provider = new CaptchaPreAuthenticationProvider(); - $provider->setManager( AuthManager::singleton() ); + $provider->setManager( MediaWikiServices::getInstance()->getAuthManager() ); $status = $provider->testForAuthentication( $req ? [ $req ] : [] ); $this->assertEquals( $result, $status->isGood() ); @@ -149,7 +150,7 @@ class CaptchaPreAuthenticationProviderTest extends MediaWikiTestCase { CaptchaStore::get()->store( '345', [ 'question' => '2+2', 'answer' => '4' ] ); $user = User::newFromName( 'Foo' ); $provider = new CaptchaPreAuthenticationProvider(); - $provider->setManager( AuthManager::singleton() ); + $provider->setManager( MediaWikiServices::getInstance()->getAuthManager() ); $status = $provider->testForAccountCreation( $user, $creator, $req ? [ $req ] : [] ); $this->assertEquals( $result, $status->isGood() ); @@ -175,7 +176,7 @@ class CaptchaPreAuthenticationProviderTest extends MediaWikiTestCase { $user = User::newFromName( 'Foo' ); $anotherUser = User::newFromName( 'Bar' ); $provider = new CaptchaPreAuthenticationProvider(); - $provider->setManager( AuthManager::singleton() ); + $provider->setManager( MediaWikiServices::getInstance()->getAuthManager() ); $this->assertFalse( $captcha->isBadLoginTriggered() ); $this->assertFalse( $captcha->isBadLoginPerUserTriggered( $user ) ); @@ -197,7 +198,7 @@ class CaptchaPreAuthenticationProviderTest extends MediaWikiTestCase { $captcha = new SimpleCaptcha(); $user = User::newFromName( 'Foo' ); $provider = new CaptchaPreAuthenticationProvider(); - $provider->setManager( AuthManager::singleton() ); + $provider->setManager( MediaWikiServices::getInstance()->getAuthManager() ); $this->assertFalse( $captcha->isBadLoginTriggered() ); $this->assertFalse( $captcha->isBadLoginPerUserTriggered( $user ) ); @@ -222,7 +223,7 @@ class CaptchaPreAuthenticationProviderTest extends MediaWikiTestCase { ] ); $provider = new CaptchaPreAuthenticationProvider(); - $provider->setManager( AuthManager::singleton() ); + $provider->setManager( MediaWikiServices::getInstance()->getAuthManager() ); $providerAccess = TestingAccessWrapper::newFromObject( $provider ); $disablePingLimiter = false;