MediaWiki REL1_31
AuthenticationResponseTest.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Auth;
4
16 public function testConstructors( $constructor, $args, $expect ) {
17 if ( is_array( $expect ) ) {
19 $res->messageType = 'warning';
20 foreach ( $expect as $field => $value ) {
21 $res->$field = $value;
22 }
23 $ret = call_user_func_array( "MediaWiki\\Auth\\AuthenticationResponse::$constructor", $args );
24 $this->assertEquals( $res, $ret );
25 } else {
26 try {
27 call_user_func_array( "MediaWiki\\Auth\\AuthenticationResponse::$constructor", $args );
28 $this->fail( 'Expected exception not thrown' );
29 } catch ( \Exception $ex ) {
30 $this->assertEquals( $expect, $ex );
31 }
32 }
33 }
34
35 public function provideConstructors() {
36 $req = $this->getMockForAbstractClass( AuthenticationRequest::class );
37 $msg = new \Message( 'mainpage' );
38
39 return [
40 [ 'newPass', [], [
42 ] ],
43 [ 'newPass', [ 'name' ], [
45 'username' => 'name',
46 ] ],
47 [ 'newPass', [ 'name', null ], [
49 'username' => 'name',
50 ] ],
51
52 [ 'newFail', [ $msg ], [
54 'message' => $msg,
55 'messageType' => 'error',
56 ] ],
57
58 [ 'newRestart', [ $msg ], [
60 'message' => $msg,
61 ] ],
62
63 [ 'newAbstain', [], [
65 ] ],
66
67 [ 'newUI', [ [ $req ], $msg ], [
69 'neededRequests' => [ $req ],
70 'message' => $msg,
71 'messageType' => 'warning',
72 ] ],
73
74 [ 'newUI', [ [ $req ], $msg, 'warning' ], [
76 'neededRequests' => [ $req ],
77 'message' => $msg,
78 'messageType' => 'warning',
79 ] ],
80
81 [ 'newUI', [ [ $req ], $msg, 'error' ], [
83 'neededRequests' => [ $req ],
84 'message' => $msg,
85 'messageType' => 'error',
86 ] ],
87 [ 'newUI', [ [], $msg ],
88 new \InvalidArgumentException( '$reqs may not be empty' )
89 ],
90
91 [ 'newRedirect', [ [ $req ], 'http://example.org/redir' ], [
93 'neededRequests' => [ $req ],
94 'redirectTarget' => 'http://example.org/redir',
95 ] ],
96 [
97 'newRedirect',
98 [ [ $req ], 'http://example.org/redir', [ 'foo' => 'bar' ] ],
99 [
101 'neededRequests' => [ $req ],
102 'redirectTarget' => 'http://example.org/redir',
103 'redirectApiData' => [ 'foo' => 'bar' ],
104 ]
105 ],
106 [ 'newRedirect', [ [], 'http://example.org/redir' ],
107 new \InvalidArgumentException( '$reqs may not be empty' )
108 ],
109 ];
110 }
111
112}
if( $line===false) $args
Definition cdb.php:64
AuthManager MediaWiki\Auth\AuthenticationResponse.
testConstructors( $constructor, $args, $expect)
provideConstructors
This is a value object to hold authentication response data.
const FAIL
Indicates that the authentication failed.
const PASS
Indicates that the authentication succeeded.
const UI
Indicates that the authentication needs further user input of some sort.
const REDIRECT
Indicates that the authentication needs to be redirected to a third party to proceed.
const ABSTAIN
Indicates that the authentication provider does not handle this request.
const RESTART
Indicates that third-party authentication succeeded but no user exists.
$res
Definition database.txt:21
this hook is for auditing only $req
Definition hooks.txt:990
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition hooks.txt:2005