mediawiki-extensions-TitleB.../tests/phpunit/TitleBlacklistPreAuthenticationProviderTest.php
vladshapik 3025d83afc Replace uses of the deprecated setters of AbstractAuthenticationProvider
Since AbstractAuthenticationProvider ::setLogger, ::setManager,
::setConfig, ::setHookContainer methods had been soft deprecated,
so its usages were removed. AuthenticationProviderTestTrait
::initProvider was used in order to initialize
TitleBlacklistPreAuthenticationProvider in the test.
* Also bump required MW version to 1.37.0

Bug: T281994
Change-Id: I15b811a8596addad7a50b13d978851ebd86da9a5
2021-05-25 16:25:07 +00:00

33 lines
1.1 KiB
PHP

<?php
use MediaWiki\Auth\AuthManager;
use MediaWiki\Tests\Unit\Auth\AuthenticationProviderTestTrait;
/**
* @group Database
* @covers TitleBlacklistPreAuthenticationProvider
*/
class TitleBlacklistPreAuthenticationProviderTest extends MediaWikiIntegrationTestCase {
use AuthenticationProviderTestTrait;
/**
* @dataProvider provideGetAuthenticationRequests
*/
public function testGetAuthenticationRequests( $action, $username, $expectedReqs ) {
$provider = new TitleBlacklistPreAuthenticationProvider();
$this->initProvider( $provider, null, null, $this->getServiceContainer()->getAuthManager() );
$reqs = $provider->getAuthenticationRequests( $action, [ 'username' => $username ] );
$this->assertEquals( $expectedReqs, $reqs );
}
public function provideGetAuthenticationRequests() {
return [
[ AuthManager::ACTION_LOGIN, null, [] ],
[ AuthManager::ACTION_CREATE, null, [] ],
[ AuthManager::ACTION_CREATE, 'UTSysop', [ new TitleBlacklistAuthenticationRequest() ] ],
[ AuthManager::ACTION_CHANGE, null, [] ],
[ AuthManager::ACTION_REMOVE, null, [] ],
];
}
}