API: Fixes for AuthManager
[mediawiki.git] / tests / phpunit / includes / auth / AbstractPreAuthenticationProviderTest.php
blobc35430e56dfb00675658ef4c4ecd7f1d88acdb95
1 <?php
3 namespace MediaWiki\Auth;
5 /**
6 * @group AuthManager
7 * @covers MediaWiki\Auth\AbstractPreAuthenticationProvider
8 */
9 class AbstractPreAuthenticationProviderTest extends \MediaWikiTestCase {
10 protected function setUp() {
11 global $wgDisableAuthManager;
13 parent::setUp();
14 if ( $wgDisableAuthManager ) {
15 $this->markTestSkipped( '$wgDisableAuthManager is set' );
19 public function testAbstractPreAuthenticationProvider() {
20 $user = \User::newFromName( 'UTSysop' );
22 $provider = $this->getMockForAbstractClass( AbstractPreAuthenticationProvider::class );
24 $this->assertEquals(
25 [],
26 $provider->getAuthenticationRequests( AuthManager::ACTION_LOGIN, [] )
28 $this->assertEquals(
29 \StatusValue::newGood(),
30 $provider->testForAuthentication( [] )
32 $this->assertEquals(
33 \StatusValue::newGood(),
34 $provider->testForAccountCreation( $user, $user, [] )
36 $this->assertEquals(
37 \StatusValue::newGood(),
38 $provider->testUserForCreation( $user, AuthManager::AUTOCREATE_SOURCE_SESSION )
40 $this->assertEquals(
41 \StatusValue::newGood(),
42 $provider->testUserForCreation( $user, false )
44 $this->assertEquals(
45 \StatusValue::newGood(),
46 $provider->testForAccountLink( $user )
49 $res = AuthenticationResponse::newPass();
50 $provider->postAuthentication( $user, $res );
51 $provider->postAccountCreation( $user, $user, $res );
52 $provider->postAccountLink( $user, $res );