Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / includes / auth / CreateFromLoginAuthenticationRequestTest.php
blob1f6b1df0e5d5cd837d00bf9f87f6dc947324d081
1 <?php
3 namespace MediaWiki\Tests\Auth;
5 use MediaWiki\Auth\AuthManager;
6 use MediaWiki\Auth\CreateFromLoginAuthenticationRequest;
7 use MediaWiki\Auth\UsernameAuthenticationRequest;
9 /**
10 * @group AuthManager
11 * @covers \MediaWiki\Auth\CreateFromLoginAuthenticationRequest
13 class CreateFromLoginAuthenticationRequestTest extends AuthenticationRequestTestCase {
15 protected function getInstance( array $args = [] ) {
16 return new CreateFromLoginAuthenticationRequest(
17 null, []
21 public static function provideLoadFromSubmission() {
22 return [
23 'Empty request' => [
24 [],
25 [],
26 [],
31 /**
32 * @dataProvider provideState
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 ) );
47 public static function provideState() {
48 $req1 = new UsernameAuthenticationRequest;
49 $req2 = new UsernameAuthenticationRequest;
50 $req2->username = 'Bob';
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 ],