3 namespace MediaWiki\Tests\Auth
;
5 use MediaWiki\Auth\AuthManager
;
6 use MediaWiki\Auth\CreateFromLoginAuthenticationRequest
;
7 use MediaWiki\Auth\UsernameAuthenticationRequest
;
11 * @covers \MediaWiki\Auth\CreateFromLoginAuthenticationRequest
13 class CreateFromLoginAuthenticationRequestTest
extends AuthenticationRequestTestCase
{
15 protected function getInstance( array $args = [] ) {
16 return new CreateFromLoginAuthenticationRequest(
21 public static function provideLoadFromSubmission() {
32 * @dataProvider provideState
34 public function testState(
35 $createReq, $maybeLink, $username, $loginState, $createState, $createPrimaryState
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
) );
47 public static function provideState() {
48 $req1 = new UsernameAuthenticationRequest
;
49 $req2 = new UsernameAuthenticationRequest
;
50 $req2->username
= 'Bob';
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 ],