Move ResultWrapper subclasses to Rdbms
[mediawiki.git] / tests / phpunit / includes / auth / ButtonAuthenticationRequestTest.php
blob3bc077cb764a6d970a8ec8ffab16d7b0cf427c2c
1 <?php
3 namespace MediaWiki\Auth;
5 /**
6 * @group AuthManager
7 * @covers MediaWiki\Auth\ButtonAuthenticationRequest
8 */
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() {
17 return [
18 [ [ 'name' => 'foo', 'label' => 'bar', 'help' => 'baz' ] ]
22 public function provideLoadFromSubmission() {
23 return [
24 'Empty request' => [
25 [ 'name' => 'foo', 'label' => 'bar', 'help' => 'baz' ],
26 [],
27 false
29 'Button present' => [
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' ) );
39 $this->assertSame(
40 'MediaWiki\\Auth\\ButtonAuthenticationRequest:foo', $req->getUniqueId()
44 public function testGetRequestByName() {
45 $reqs = [];
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' ) ] )
53 ->getMock();
55 $this->assertNull( ButtonAuthenticationRequest::getRequestByName( $reqs, 'missing' ) );
56 $this->assertSame(
57 $reqs['testOne'], ButtonAuthenticationRequest::getRequestByName( $reqs, 'foo' )
59 $this->assertNull( ButtonAuthenticationRequest::getRequestByName( $reqs, 'bar' ) );
60 $this->assertSame(
61 $reqs['testSub'], ButtonAuthenticationRequest::getRequestByName( $reqs, 'subclass' )