Merge "Update docs/hooks.txt for ShowSearchHitTitle"
[mediawiki.git] / tests / phpunit / includes / auth / CreateFromLoginAuthenticationRequestTest.php
blobd166caa64e39122acd14bc57292f9775e637ed01
1 <?php
3 namespace MediaWiki\Auth;
5 /**
6 * @group AuthManager
7 * @covers MediaWiki\Auth\CreateFromLoginAuthenticationRequest
8 */
9 class CreateFromLoginAuthenticationRequestTest extends AuthenticationRequestTestCase {
11 protected function getInstance( array $args = [] ) {
12 return new CreateFromLoginAuthenticationRequest(
13 null, []
17 public function provideLoadFromSubmission() {
18 return [
19 'Empty request' => [
20 [],
21 [],
22 [],
27 /**
28 * @dataProvider provideState
30 public function testState(
31 $createReq, $maybeLink, $username, $loginState, $createState, $createPrimaryState
32 ) {
33 $req = new CreateFromLoginAuthenticationRequest( $createReq, $maybeLink );
34 $this->assertSame( $username, $req->username );
35 $this->assertSame( $loginState, $req->hasStateForAction( AuthManager::ACTION_LOGIN ) );
36 $this->assertSame( $createState, $req->hasStateForAction( AuthManager::ACTION_CREATE ) );
37 $this->assertFalse( $req->hasStateForAction( AuthManager::ACTION_LINK ) );
38 $this->assertFalse( $req->hasPrimaryStateForAction( AuthManager::ACTION_LOGIN ) );
39 $this->assertSame( $createPrimaryState,
40 $req->hasPrimaryStateForAction( AuthManager::ACTION_CREATE ) );
43 public static function provideState() {
44 $req1 = new UsernameAuthenticationRequest;
45 $req2 = new UsernameAuthenticationRequest;
46 $req2->username = 'Bob';
48 return [
49 'Nothing' => [ null, [], null, false, false, false ],
50 'Link, no create' => [ null, [ $req2 ], null, true, true, false ],
51 'No link, create but no name' => [ $req1, [], null, false, true, true ],
52 'Link and create but no name' => [ $req1, [ $req2 ], null, true, true, true ],
53 'No link, create with name' => [ $req2, [], 'Bob', false, true, true ],
54 'Link and create with name' => [ $req2, [ $req2 ], 'Bob', true, true, true ],