Merge "Disable Cucumber scenarios that are broken in daily Jenkins jobs"
[lhc/web/wiklou.git] / tests / phpunit / includes / auth / AbstractPreAuthenticationProviderTest.php
1 <?php
2
3 namespace MediaWiki\Auth;
4
5 /**
6 * @group AuthManager
7 * @covers MediaWiki\Auth\AbstractPreAuthenticationProvider
8 */
9 class AbstractPreAuthenticationProviderTest extends \MediaWikiTestCase {
10 protected function setUp() {
11 global $wgDisableAuthManager;
12
13 parent::setUp();
14 if ( $wgDisableAuthManager ) {
15 $this->markTestSkipped( '$wgDisableAuthManager is set' );
16 }
17 }
18
19 public function testAbstractPreAuthenticationProvider() {
20 $user = \User::newFromName( 'UTSysop' );
21
22 $provider = $this->getMockForAbstractClass( AbstractPreAuthenticationProvider::class );
23
24 $this->assertEquals(
25 [],
26 $provider->getAuthenticationRequests( AuthManager::ACTION_LOGIN, [] )
27 );
28 $this->assertEquals(
29 \StatusValue::newGood(),
30 $provider->testForAuthentication( [] )
31 );
32 $this->assertEquals(
33 \StatusValue::newGood(),
34 $provider->testForAccountCreation( $user, $user, [] )
35 );
36 $this->assertEquals(
37 \StatusValue::newGood(),
38 $provider->testUserForCreation( $user, AuthManager::AUTOCREATE_SOURCE_SESSION )
39 );
40 $this->assertEquals(
41 \StatusValue::newGood(),
42 $provider->testUserForCreation( $user, false )
43 );
44 $this->assertEquals(
45 \StatusValue::newGood(),
46 $provider->testForAccountLink( $user )
47 );
48
49 $res = AuthenticationResponse::newPass();
50 $provider->postAuthentication( $user, $res );
51 $provider->postAccountCreation( $user, $user, $res );
52 $provider->postAccountLink( $user, $res );
53 }
54 }