3 namespace MediaWiki\Tests\Auth
;
5 use MediaWiki\Auth\ButtonAuthenticationRequest
;
9 * @covers \MediaWiki\Auth\ButtonAuthenticationRequest
11 class ButtonAuthenticationRequestTest
extends AuthenticationRequestTestCase
{
13 protected function getInstance( array $args = [] ) {
14 $data = array_intersect_key( $args, [ 'name' => 1, 'label' => 1, 'help' => 1 ] );
15 if ( $args['name'] === 'foo' ) {
16 return ButtonAuthenticationRequestForLoadFromSubmission
::__set_state( $data );
18 return ButtonAuthenticationRequest
::__set_state( $data );
21 public static function provideGetFieldInfo() {
23 [ [ 'name' => 'foo', 'label' => 'bar', 'help' => 'baz' ] ]
27 public static function provideLoadFromSubmission() {
30 [ 'name' => 'foo', 'label' => 'bar', 'help' => 'baz' ],
35 [ 'name' => 'foo', 'label' => 'bar', 'help' => 'baz' ],
36 [ 'foo' => 'Foobar' ],
37 [ 'name' => 'foo', 'label' => 'bar', 'help' => 'baz', 'foo' => true ]
42 public function testGetUniqueId() {
43 $req = new ButtonAuthenticationRequest( 'foo', wfMessage( 'bar' ), wfMessage( 'baz' ) );
45 'MediaWiki\\Auth\\ButtonAuthenticationRequest:foo', $req->getUniqueId()
49 public function testGetRequestByName() {
51 $reqs['testOne'] = new ButtonAuthenticationRequest(
52 'foo', wfMessage( 'msg' ), wfMessage( 'help' )
54 $reqs[] = new ButtonAuthenticationRequest( 'bar', wfMessage( 'msg1' ), wfMessage( 'help1' ) );
55 $reqs[] = new ButtonAuthenticationRequest( 'bar', wfMessage( 'msg2' ), wfMessage( 'help2' ) );
57 new ButtonAuthenticationRequest( 'subclass', wfMessage( 'msg3' ), wfMessage( 'help3' ) );
59 $this->assertNull( ButtonAuthenticationRequest
::getRequestByName( $reqs, 'missing' ) );
61 $reqs['testOne'], ButtonAuthenticationRequest
::getRequestByName( $reqs, 'foo' )
63 $this->assertNull( ButtonAuthenticationRequest
::getRequestByName( $reqs, 'bar' ) );
65 $reqs['testSub'], ButtonAuthenticationRequest
::getRequestByName( $reqs, 'subclass' )
70 // Dynamic properties from the testLoadFromSubmission not working in php8.2
71 class ButtonAuthenticationRequestForLoadFromSubmission
extends ButtonAuthenticationRequest
{