1<?php
2
3namespace MediaWiki\Auth;
4
5/**
6 * @group AuthManager
7 * @covers \MediaWiki\Auth\AbstractPreAuthenticationProvider
8 */
9class AbstractPreAuthenticationProviderTest extends \MediaWikiIntegrationTestCase {
10	public function testAbstractPreAuthenticationProvider() {
11		$user = \User::newFromName( 'UTSysop' );
12
13		$provider = $this->getMockForAbstractClass( AbstractPreAuthenticationProvider::class );
14
15		$this->assertEquals(
16			[],
17			$provider->getAuthenticationRequests( AuthManager::ACTION_LOGIN, [] )
18		);
19		$this->assertEquals(
20			\StatusValue::newGood(),
21			$provider->testForAuthentication( [] )
22		);
23		$this->assertEquals(
24			\StatusValue::newGood(),
25			$provider->testForAccountCreation( $user, $user, [] )
26		);
27		$this->assertEquals(
28			\StatusValue::newGood(),
29			$provider->testUserForCreation( $user, AuthManager::AUTOCREATE_SOURCE_SESSION )
30		);
31		$this->assertEquals(
32			\StatusValue::newGood(),
33			$provider->testUserForCreation( $user, false )
34		);
35		$this->assertEquals(
36			\StatusValue::newGood(),
37			$provider->testForAccountLink( $user )
38		);
39
40		$res = AuthenticationResponse::newPass();
41		$provider->postAuthentication( $user, $res );
42		$provider->postAccountCreation( $user, $user, $res );
43		$provider->postAccountLink( $user, $res );
44	}
45}
46