Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / includes / auth / ButtonAuthenticationRequestTest.php
blobf61b6005e5d064dd3311474a4f37d7f9324de689
1 <?php
3 namespace MediaWiki\Tests\Auth;
5 use MediaWiki\Auth\ButtonAuthenticationRequest;
7 /**
8 * @group AuthManager
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() {
22 return [
23 [ [ 'name' => 'foo', 'label' => 'bar', 'help' => 'baz' ] ]
27 public static function provideLoadFromSubmission() {
28 return [
29 'Empty request' => [
30 [ 'name' => 'foo', 'label' => 'bar', 'help' => 'baz' ],
31 [],
32 false
34 'Button present' => [
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' ) );
44 $this->assertSame(
45 'MediaWiki\\Auth\\ButtonAuthenticationRequest:foo', $req->getUniqueId()
49 public function testGetRequestByName() {
50 $reqs = [];
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' ) );
56 $reqs['testSub'] =
57 new ButtonAuthenticationRequest( 'subclass', wfMessage( 'msg3' ), wfMessage( 'help3' ) );
59 $this->assertNull( ButtonAuthenticationRequest::getRequestByName( $reqs, 'missing' ) );
60 $this->assertSame(
61 $reqs['testOne'], ButtonAuthenticationRequest::getRequestByName( $reqs, 'foo' )
63 $this->assertNull( ButtonAuthenticationRequest::getRequestByName( $reqs, 'bar' ) );
64 $this->assertSame(
65 $reqs['testSub'], ButtonAuthenticationRequest::getRequestByName( $reqs, 'subclass' )
70 // Dynamic properties from the testLoadFromSubmission not working in php8.2
71 class ButtonAuthenticationRequestForLoadFromSubmission extends ButtonAuthenticationRequest {
72 /** @var string */
73 public $foo;