Merge "Update docs/hooks.txt for ShowSearchHitTitle"
[mediawiki.git] / tests / phpunit / includes / auth / ConfirmLinkAuthenticationRequestTest.php
blobf208cc4be7f62f9dd2db6c317b176ac58b8c6baf
1 <?php
3 namespace MediaWiki\Auth;
5 use InvalidArgumentException;
7 /**
8 * @group AuthManager
9 * @covers MediaWiki\Auth\ConfirmLinkAuthenticationRequest
11 class ConfirmLinkAuthenticationRequestTest extends AuthenticationRequestTestCase {
13 protected function getInstance( array $args = [] ) {
14 return new ConfirmLinkAuthenticationRequest( $this->getLinkRequests() );
17 /**
18 * @expectedException InvalidArgumentException
19 * @expectedExceptionMessage $linkRequests must not be empty
21 public function testConstructorException() {
22 new ConfirmLinkAuthenticationRequest( [] );
25 /**
26 * Get requests for testing
27 * @return AuthenticationRequest[]
29 private function getLinkRequests() {
30 $reqs = [];
32 $mb = $this->getMockBuilder( AuthenticationRequest::class )
33 ->setMethods( [ 'getUniqueId' ] );
34 for ( $i = 1; $i <= 3; $i++ ) {
35 $req = $mb->getMockForAbstractClass();
36 $req->expects( $this->any() )->method( 'getUniqueId' )
37 ->will( $this->returnValue( "Request$i" ) );
38 $reqs[$req->getUniqueId()] = $req;
41 return $reqs;
44 public function provideLoadFromSubmission() {
45 $reqs = $this->getLinkRequests();
47 return [
48 'Empty request' => [
49 [],
50 [],
51 [ 'linkRequests' => $reqs ],
53 'Some confirmed' => [
54 [],
55 [ 'confirmedLinkIDs' => [ 'Request1', 'Request3' ] ],
56 [ 'confirmedLinkIDs' => [ 'Request1', 'Request3' ], 'linkRequests' => $reqs ],
61 public function testGetUniqueId() {
62 $req = new ConfirmLinkAuthenticationRequest( $this->getLinkRequests() );
63 $this->assertSame(
64 get_class( $req ) . ':Request1|Request2|Request3',
65 $req->getUniqueId()