Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / includes / auth / ConfirmLinkAuthenticationRequestTest.php
blob28e5a6804ab67075bb7a8c0c0ffc4464317e7238
1 <?php
3 namespace MediaWiki\Tests\Auth;
5 use InvalidArgumentException;
6 use MediaWiki\Auth\AuthenticationRequest;
7 use MediaWiki\Auth\ConfirmLinkAuthenticationRequest;
9 /**
10 * @group AuthManager
11 * @covers \MediaWiki\Auth\ConfirmLinkAuthenticationRequest
13 class ConfirmLinkAuthenticationRequestTest extends AuthenticationRequestTestCase {
15 protected function getInstance( array $args = [] ) {
16 return new ConfirmLinkAuthenticationRequest( self::getLinkRequests() );
19 public function testConstructorException() {
20 $this->expectException( InvalidArgumentException::class );
21 $this->expectExceptionMessage( '$linkRequests must not be empty' );
22 new ConfirmLinkAuthenticationRequest( [] );
25 /**
26 * Get requests for testing
27 * @return AuthenticationRequest[]
29 private static function getLinkRequests() {
30 $reqs = [];
32 for ( $i = 1; $i <= 3; $i++ ) {
33 $req = new class( "Request$i" ) extends AuthenticationRequest {
34 private $uniqueId;
36 public function __construct( $uniqueId ) {
37 $this->uniqueId = $uniqueId;
40 public function getFieldInfo() {
41 return [];
44 public function getUniqueId() {
45 return $this->uniqueId;
49 $reqs[$req->getUniqueId()] = $req;
52 return $reqs;
55 public static function provideLoadFromSubmission() {
56 $reqs = self::getLinkRequests();
58 return [
59 'Empty request' => [
60 [],
61 [],
62 [ 'linkRequests' => $reqs ],
64 'Some confirmed' => [
65 [],
66 [ 'confirmedLinkIDs' => [ 'Request1', 'Request3' ] ],
67 [ 'confirmedLinkIDs' => [ 'Request1', 'Request3' ], 'linkRequests' => $reqs ],
72 public function testGetUniqueId() {
73 $req = new ConfirmLinkAuthenticationRequest( self::getLinkRequests() );
74 $this->assertSame(
75 get_class( $req ) . ':Request1|Request2|Request3',
76 $req->getUniqueId()