3 namespace MediaWiki\Tests\Auth
;
5 use InvalidArgumentException
;
6 use MediaWiki\Auth\AuthenticationRequest
;
7 use MediaWiki\Auth\ConfirmLinkAuthenticationRequest
;
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( [] );
26 * Get requests for testing
27 * @return AuthenticationRequest[]
29 private static function getLinkRequests() {
32 for ( $i = 1; $i <= 3; $i++
) {
33 $req = new class( "Request$i" ) extends AuthenticationRequest
{
36 public function __construct( $uniqueId ) {
37 $this->uniqueId
= $uniqueId;
40 public function getFieldInfo() {
44 public function getUniqueId() {
45 return $this->uniqueId
;
49 $reqs[$req->getUniqueId()] = $req;
55 public static function provideLoadFromSubmission() {
56 $reqs = self
::getLinkRequests();
62 [ 'linkRequests' => $reqs ],
66 [ 'confirmedLinkIDs' => [ 'Request1', 'Request3' ] ],
67 [ 'confirmedLinkIDs' => [ 'Request1', 'Request3' ], 'linkRequests' => $reqs ],
72 public function testGetUniqueId() {
73 $req = new ConfirmLinkAuthenticationRequest( self
::getLinkRequests() );
75 get_class( $req ) . ':Request1|Request2|Request3',