aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit
diff options
context:
space:
mode:
authorUmherirrender <umherirrender_de.wp@web.de>2020-10-30 11:55:50 +0100
committerUmherirrender <umherirrender_de.wp@web.de>2020-10-30 14:52:08 +0100
commit64b8d8ad425360e60a70d81edf95b29bf8b7e756 (patch)
tree9ba3cf932cc17cad461ad7c0f5b29bc64376c1a8 /tests/phpunit
parent27f2ce8b221b0f46e7296d60239ca356c9b2963b (diff)
downloadmediawikicore-64b8d8ad425360e60a70d81edf95b29bf8b7e756.tar.gz
mediawikicore-64b8d8ad425360e60a70d81edf95b29bf8b7e756.zip
Inject BlockManager and BlockErrorFormatter into AuthManager
Change-Id: Icf5a68fa9477bb30afd6f3dd32d96ae44e95fed2
Diffstat (limited to 'tests/phpunit')
-rw-r--r--tests/phpunit/includes/auth/AbstractPasswordPrimaryAuthenticationProviderTest.php4
-rw-r--r--tests/phpunit/includes/auth/AuthManagerTest.php18
-rw-r--r--tests/phpunit/includes/auth/ConfirmLinkSecondaryAuthenticationProviderTest.php15
-rw-r--r--tests/phpunit/includes/auth/EmailNotificationSecondaryAuthenticationProviderTest.php7
-rw-r--r--tests/phpunit/includes/auth/LocalPasswordPrimaryAuthenticationProviderTest.php9
-rw-r--r--tests/phpunit/includes/auth/ResetPasswordSecondaryAuthenticationProviderTest.php7
-rw-r--r--tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php9
7 files changed, 52 insertions, 17 deletions
diff --git a/tests/phpunit/includes/auth/AbstractPasswordPrimaryAuthenticationProviderTest.php b/tests/phpunit/includes/auth/AbstractPasswordPrimaryAuthenticationProviderTest.php
index 92794d46d5be..de21bd1a1dd6 100644
--- a/tests/phpunit/includes/auth/AbstractPasswordPrimaryAuthenticationProviderTest.php
+++ b/tests/phpunit/includes/auth/AbstractPasswordPrimaryAuthenticationProviderTest.php
@@ -131,7 +131,9 @@ class AbstractPasswordPrimaryAuthenticationProviderTest extends \MediaWikiIntegr
$services->getPermissionManager(),
$services->getHookContainer(),
$services->getReadOnlyMode(),
- $services->getUserNameUtils()
+ $services->getUserNameUtils(),
+ $services->getBlockManager(),
+ $services->getBlockErrorFormatter()
);
$provider = $this->getMockForAbstractClass(
diff --git a/tests/phpunit/includes/auth/AuthManagerTest.php b/tests/phpunit/includes/auth/AuthManagerTest.php
index b92dbd5af324..54c467d842e7 100644
--- a/tests/phpunit/includes/auth/AuthManagerTest.php
+++ b/tests/phpunit/includes/auth/AuthManagerTest.php
@@ -7,6 +7,8 @@ use MediaWiki\Auth\Hook\AuthManagerLoginAuthenticateAuditHook;
use MediaWiki\Auth\Hook\LocalUserCreatedHook;
use MediaWiki\Auth\Hook\SecuritySensitiveOperationStatusHook;
use MediaWiki\Auth\Hook\UserLoggedInHook;
+use MediaWiki\Block\BlockErrorFormatter;
+use MediaWiki\Block\BlockManager;
use MediaWiki\Block\DatabaseBlock;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\HookContainer\StaticHookRegistry;
@@ -63,6 +65,12 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
/** @var TestingAccessWrapper */
protected $managerPriv;
+ /** @var BlockManager */
+ private $blockManager;
+
+ /** @var BlockErrorFormatter */
+ private $blockErrorFormatter;
+
/**
* Sets a mock on a hook
* @param string $hook
@@ -178,6 +186,12 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
if ( $regen || !$this->readOnlyMode ) {
$this->readOnlyMode = MediaWikiServices::getInstance()->getReadOnlyMode();
}
+ if ( $regen || !$this->blockManager ) {
+ $this->blockManager = MediaWikiServices::getInstance()->getBlockManager();
+ }
+ if ( $regen || !$this->blockErrorFormatter ) {
+ $this->blockErrorFormatter = MediaWikiServices::getInstance()->getBlockErrorFormatter();
+ }
if ( $regen || !$this->hookContainer ) {
// Set up a HookContainer similar to the normal one except that it
// gets global hooks from $this->authHooks instead of $wgHooks
@@ -214,7 +228,9 @@ class AuthManagerTest extends \MediaWikiIntegrationTestCase {
$this->permManager,
$this->hookContainer,
$this->readOnlyMode,
- $this->userNameUtils
+ $this->userNameUtils,
+ $this->blockManager,
+ $this->blockErrorFormatter
);
$this->manager->setLogger( $this->logger );
$this->managerPriv = TestingAccessWrapper::newFromObject( $this->manager );
diff --git a/tests/phpunit/includes/auth/ConfirmLinkSecondaryAuthenticationProviderTest.php b/tests/phpunit/includes/auth/ConfirmLinkSecondaryAuthenticationProviderTest.php
index ecf556b2cf96..722ca29c97e7 100644
--- a/tests/phpunit/includes/auth/ConfirmLinkSecondaryAuthenticationProviderTest.php
+++ b/tests/phpunit/includes/auth/ConfirmLinkSecondaryAuthenticationProviderTest.php
@@ -136,16 +136,19 @@ class ConfirmLinkSecondaryAuthenticationProviderTest extends \MediaWikiIntegrati
new ConfirmLinkSecondaryAuthenticationProvider
);
$request = new \FauxRequest();
+ $mwServices = MediaWikiServices::getInstance();
$manager = $this->getMockBuilder( AuthManager::class )
->setMethods( [ 'allowsAuthenticationDataChange' ] )
->setConstructorArgs( [
$request,
\RequestContext::getMain()->getConfig(),
- MediaWikiServices::getInstance()->getObjectFactory(),
+ $mwServices->getObjectFactory(),
$this->createNoOpMock( PermissionManager::class ),
- MediaWikiServices::getInstance()->getHookContainer(),
- MediaWikiServices::getInstance()->getReadOnlyMode(),
- $this->createNoOpMock( UserNameUtils::class )
+ $mwServices->getHookContainer(),
+ $mwServices->getReadOnlyMode(),
+ $this->createNoOpMock( UserNameUtils::class ),
+ $mwServices->getBlockManager(),
+ $mwServices->getBlockErrorFormatter()
] )
->getMock();
$manager->expects( $this->any() )->method( 'allowsAuthenticationDataChange' )
@@ -250,7 +253,9 @@ class ConfirmLinkSecondaryAuthenticationProviderTest extends \MediaWikiIntegrati
$permManager,
$hookContainer,
$readOnlyMode,
- $userNameUtils
+ $userNameUtils,
+ $mwServices->getBlockManager(),
+ $mwServices->getBlockErrorFormatter()
);
$provider->setManager( $manager );
$provider = TestingAccessWrapper::newFromObject( $provider );
diff --git a/tests/phpunit/includes/auth/EmailNotificationSecondaryAuthenticationProviderTest.php b/tests/phpunit/includes/auth/EmailNotificationSecondaryAuthenticationProviderTest.php
index 767f075df240..80dc34b8ff4e 100644
--- a/tests/phpunit/includes/auth/EmailNotificationSecondaryAuthenticationProviderTest.php
+++ b/tests/phpunit/includes/auth/EmailNotificationSecondaryAuthenticationProviderTest.php
@@ -63,6 +63,7 @@ class EmailNotificationSecondaryAuthenticationProviderTest extends \MediaWikiInt
}
public function testBeginSecondaryAccountCreation() {
+ $mwServices = MediaWikiServices::getInstance();
$services = $this->createNoOpAbstractMock( ContainerInterface::class );
$objectFactory = new \Wikimedia\ObjectFactory( $services );
$permManager = $this->createNoOpMock( PermissionManager::class );
@@ -74,8 +75,10 @@ class EmailNotificationSecondaryAuthenticationProviderTest extends \MediaWikiInt
$objectFactory,
$permManager,
$hookContainer,
- MediaWikiServices::getInstance()->getReadOnlyMode(),
- $userNameUtils
+ $mwServices->getReadOnlyMode(),
+ $userNameUtils,
+ $mwServices->getBlockManager(),
+ $mwServices->getBlockErrorFormatter()
);
$creator = $this->getMockBuilder( \User::class )->getMock();
diff --git a/tests/phpunit/includes/auth/LocalPasswordPrimaryAuthenticationProviderTest.php b/tests/phpunit/includes/auth/LocalPasswordPrimaryAuthenticationProviderTest.php
index 0bf0c1c4e90f..c700815fd099 100644
--- a/tests/phpunit/includes/auth/LocalPasswordPrimaryAuthenticationProviderTest.php
+++ b/tests/phpunit/includes/auth/LocalPasswordPrimaryAuthenticationProviderTest.php
@@ -29,6 +29,7 @@ class LocalPasswordPrimaryAuthenticationProviderTest extends \MediaWikiIntegrati
* @return LocalPasswordPrimaryAuthenticationProvider
*/
protected function getProvider( $loginOnly = false ) {
+ $mwServices = MediaWikiServices::getInstance();
if ( !$this->config ) {
$this->config = new \HashConfig();
}
@@ -39,7 +40,7 @@ class LocalPasswordPrimaryAuthenticationProviderTest extends \MediaWikiIntegrati
// We need a real HookContainer since testProviderChangeAuthenticationData()
// modifies $wgHooks
- $hookContainer = MediaWikiServices::getInstance()->getHookContainer();
+ $hookContainer = $mwServices->getHookContainer();
if ( !$this->manager ) {
$services = $this->createNoOpAbstractMock( ContainerInterface::class );
@@ -53,8 +54,10 @@ class LocalPasswordPrimaryAuthenticationProviderTest extends \MediaWikiIntegrati
$objectFactory,
$permManager,
$hookContainer,
- MediaWikiServices::getInstance()->getReadOnlyMode(),
- $userNameUtils
+ $mwServices->getReadOnlyMode(),
+ $userNameUtils,
+ $mwServices->getBlockManager(),
+ $mwServices->getBlockErrorFormatter()
);
}
$this->validity = \Status::newGood();
diff --git a/tests/phpunit/includes/auth/ResetPasswordSecondaryAuthenticationProviderTest.php b/tests/phpunit/includes/auth/ResetPasswordSecondaryAuthenticationProviderTest.php
index 7468512ef97c..dee22661ade9 100644
--- a/tests/phpunit/includes/auth/ResetPasswordSecondaryAuthenticationProviderTest.php
+++ b/tests/phpunit/includes/auth/ResetPasswordSecondaryAuthenticationProviderTest.php
@@ -89,6 +89,7 @@ class ResetPasswordSecondaryAuthenticationProviderTest extends \MediaWikiIntegra
],
],
] );
+ $mwServices = MediaWikiServices::getInstance();
$services = $this->createNoOpAbstractMock( ContainerInterface::class );
$objectFactory = new \Wikimedia\ObjectFactory( $services );
$permManager = $this->createNoOpMock( PermissionManager::class );
@@ -100,8 +101,10 @@ class ResetPasswordSecondaryAuthenticationProviderTest extends \MediaWikiIntegra
$objectFactory,
$permManager,
$hookContainer,
- MediaWikiServices::getInstance()->getReadOnlyMode(),
- $userNameUtils
+ $mwServices->getReadOnlyMode(),
+ $userNameUtils,
+ $mwServices->getBlockManager(),
+ $mwServices->getBlockErrorFormatter()
);
$provider->setManager( $manager );
$provider = TestingAccessWrapper::newFromObject( $provider );
diff --git a/tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php b/tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php
index 70a9b4a3270c..b4f4261cc054 100644
--- a/tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php
+++ b/tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php
@@ -30,6 +30,7 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiInteg
* @return TemporaryPasswordPrimaryAuthenticationProvider
*/
protected function getProvider( $params = [] ) {
+ $mwServices = MediaWikiServices::getInstance();
if ( !$this->config ) {
$this->config = new \HashConfig( [
'EmailEnabled' => true,
@@ -37,7 +38,7 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiInteg
}
$config = new \MultiConfig( [
$this->config,
- MediaWikiServices::getInstance()->getMainConfig()
+ $mwServices->getMainConfig()
] );
$hookContainer = $this->createHookContainer();
@@ -53,8 +54,10 @@ class TemporaryPasswordPrimaryAuthenticationProviderTest extends \MediaWikiInteg
$objectFactory,
$permManager,
$hookContainer,
- MediaWikiServices::getInstance()->getReadOnlyMode(),
- $userNameUtils
+ $mwServices->getReadOnlyMode(),
+ $userNameUtils,
+ $mwServices->getBlockManager(),
+ $mwServices->getBlockErrorFormatter()
);
}
$this->validity = \Status::newGood();