3 namespace MediaWiki\Auth
;
7 * @covers MediaWiki\Auth\ButtonAuthenticationRequest
9 class ButtonAuthenticationRequestTest
extends AuthenticationRequestTestCase
{
11 protected function getInstance( array $args = [] ) {
12 $data = array_intersect_key( $args, [ 'name' => 1, 'label' => 1, 'help' => 1 ] );
13 return ButtonAuthenticationRequest
::__set_state( $data );
16 public static function provideGetFieldInfo() {
18 [ [ 'name' => 'foo', 'label' => 'bar', 'help' => 'baz' ] ]
22 public function provideLoadFromSubmission() {
25 [ 'name' => 'foo', 'label' => 'bar', 'help' => 'baz' ],
30 [ 'name' => 'foo', 'label' => 'bar', 'help' => 'baz' ],
31 [ 'foo' => 'Foobar' ],
32 [ 'name' => 'foo', 'label' => 'bar', 'help' => 'baz', 'foo' => true ]
37 public function testGetUniqueId() {
38 $req = new ButtonAuthenticationRequest( 'foo', wfMessage( 'bar' ), wfMessage( 'baz' ) );
40 'MediaWiki\\Auth\\ButtonAuthenticationRequest:foo', $req->getUniqueId()
44 public function testGetRequestByName() {
46 $reqs['testOne'] = new ButtonAuthenticationRequest(
47 'foo', wfMessage( 'msg' ), wfMessage( 'help' )
49 $reqs[] = new ButtonAuthenticationRequest( 'bar', wfMessage( 'msg1' ), wfMessage( 'help1' ) );
50 $reqs[] = new ButtonAuthenticationRequest( 'bar', wfMessage( 'msg2' ), wfMessage( 'help2' ) );
51 $reqs['testSub'] = $this->getMockBuilder( ButtonAuthenticationRequest
::class )
52 ->setConstructorArgs( [ 'subclass', wfMessage( 'msg3' ), wfMessage( 'help3' ) ] )
55 $this->assertNull( ButtonAuthenticationRequest
::getRequestByName( $reqs, 'missing' ) );
57 $reqs['testOne'], ButtonAuthenticationRequest
::getRequestByName( $reqs, 'foo' )
59 $this->assertNull( ButtonAuthenticationRequest
::getRequestByName( $reqs, 'bar' ) );
61 $reqs['testSub'], ButtonAuthenticationRequest
::getRequestByName( $reqs, 'subclass' )