Debian Codegraph @

tests/phpunit/includes/auth/CreateFromLoginAuthenticationRequestTest.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Tests\Auth;
4
5 use MediaWiki\Auth\AuthManager;
6 use MediaWiki\Auth\CreateFromLoginAuthenticationRequest;
7 use MediaWiki\Auth\UsernameAuthenticationRequest;
8
9 /**
10 * @group AuthManager
11 * @covers \MediaWiki\Auth\CreateFromLoginAuthenticationRequest
12 */
13 class CreateFromLoginAuthenticationRequestTest extends AuthenticationRequestTestCase {
14
15 protected function getInstance( array $args = [] ) {
16 return new CreateFromLoginAuthenticationRequest(
17 null, []
18 );
19 }
20
21 public static function provideLoadFromSubmission() {
22 return [
23 'Empty request' => [
24 [],
25 [],
26 [],
27 ],
28 ];
29 }
30
31 /**
32 * @dataProvider provideState
33 */
34 public function testState(
35 $createReq, $maybeLink, $username, $loginState, $createState, $createPrimaryState
36 ) {
37 $req = new CreateFromLoginAuthenticationRequest( $createReq, $maybeLink );
38 $this->assertSame( $username, $req->username );
39 $this->assertSame( $loginState, $req->hasStateForAction( AuthManager::ACTION_LOGIN ) );
40 $this->assertSame( $createState, $req->hasStateForAction( AuthManager::ACTION_CREATE ) );
41 $this->assertFalse( $req->hasStateForAction( AuthManager::ACTION_LINK ) );
42 $this->assertFalse( $req->hasPrimaryStateForAction( AuthManager::ACTION_LOGIN ) );
43 $this->assertSame( $createPrimaryState,
44 $req->hasPrimaryStateForAction( AuthManager::ACTION_CREATE ) );
45 }
46
47 public static function provideState() {
48 $req1 = new UsernameAuthenticationRequest;
49 $req2 = new UsernameAuthenticationRequest;
50 $req2->username = 'Bob';
51
52 return [
53 'Nothing' => [ null, [], null, false, false, false ],
54 'Link, no create' => [ null, [ $req2 ], null, true, true, false ],
55 'No link, create but no name' => [ $req1, [], null, false, true, true ],
56 'Link and create but no name' => [ $req1, [ $req2 ], null, true, true, true ],
57 'No link, create with name' => [ $req2, [], 'Bob', false, true, true ],
58 'Link and create with name' => [ $req2, [ $req2 ], 'Bob', true, true, true ],
59 ];
60 }
61 }