]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - extensions/TitleBlacklist/tests/phpunit/TitleBlacklistPreAuthenticationProviderTest.php
MediaWiki 1.30.2
[autoinstalls/mediawiki.git] / extensions / TitleBlacklist / tests / phpunit / TitleBlacklistPreAuthenticationProviderTest.php
1 <?php
2 use MediaWiki\Auth\AuthManager;
3
4 /**
5  * @group Database
6  */
7 class TitleBlacklistPreAuthenticationProviderTest extends MediaWikiTestCase {
8         public function setUp() {
9                 global $wgDisableAuthManager;
10                 if ( !class_exists( AuthManager::class ) || $wgDisableAuthManager ) {
11                         $this->markTestSkipped( 'AuthManager is disabled' );
12                 }
13
14                 parent::setUp();
15         }
16
17         /**
18          * @dataProvider provideGetAuthenticationRequests
19          */
20         public function testGetAuthenticationRequests( $action, $username, $expectedReqs ) {
21                 $provider = new TitleBlacklistPreAuthenticationProvider();
22                 $provider->setManager( AuthManager::singleton() );
23                 $reqs = $provider->getAuthenticationRequests( $action, [ 'username' => $username ] );
24                 $this->assertEquals( $expectedReqs, $reqs );
25         }
26
27         public function provideGetAuthenticationRequests() {
28                 return [
29                         [ AuthManager::ACTION_LOGIN, null, [] ],
30                         [ AuthManager::ACTION_CREATE, null, [] ],
31                         [ AuthManager::ACTION_CREATE, 'UTSysop', [ new TitleBlacklistAuthenticationRequest() ] ],
32                         [ AuthManager::ACTION_CHANGE, null, [] ],
33                         [ AuthManager::ACTION_REMOVE, null, [] ],
34                 ];
35         }
36 }