MediaWiki REL1_33
UserDataAuthenticationRequestTest.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Auth;
4
10
11 protected function getInstance( array $args = [] ) {
13 }
14
15 protected function setUp() {
16 parent::setUp();
17 $this->setMwGlobals( 'wgHiddenPrefs', [] );
18 }
19
26 public function testPopulateUser( $email, $realname, $expect ) {
27 $user = new \User();
28 $user->setEmail( 'default@example.com' );
29 $user->setRealName( 'Fake Name' );
30
32 $req->email = $email;
33 $req->realname = $realname;
34 $this->assertEquals( $expect, $req->populateUser( $user ) );
35 if ( $expect->isOk() ) {
36 $this->assertSame( $email ?: 'default@example.com', $user->getEmail() );
37 $this->assertSame( $realname ?: 'Fake Name', $user->getRealName() );
38 }
39 }
40
41 public static function providePopulateUser() {
42 $good = \StatusValue::newGood();
43 return [
44 [ 'email@example.com', 'Real Name', $good ],
45 [ 'email@example.com', '', $good ],
46 [ '', 'Real Name', $good ],
47 [ '', '', $good ],
48 [ 'invalid-email', 'Real Name', \StatusValue::newFatal( 'invalidemailaddress' ) ],
49 ];
50 }
51
55 public function testLoadFromSubmission(
56 array $args, array $data, $expectState /* $hiddenPref, $enableEmail */
57 ) {
58 list( $args, $data, $expectState, $hiddenPref, $enableEmail ) = func_get_args();
59 $this->setMwGlobals( 'wgHiddenPrefs', $hiddenPref );
60 $this->setMwGlobals( 'wgEnableEmail', $enableEmail );
61 parent::testLoadFromSubmission( $args, $data, $expectState );
62 }
63
64 public function provideLoadFromSubmission() {
65 $unhidden = [];
66 $hidden = [ 'realname' ];
67
68 return [
69 'Empty request, unhidden, email enabled' => [
70 [],
71 [],
72 false,
73 $unhidden,
74 true
75 ],
76 'email + realname, unhidden, email enabled' => [
77 [],
78 $data = [ 'email' => 'Email', 'realname' => 'Name' ],
79 $data,
80 $unhidden,
81 true
82 ],
83 'email empty, unhidden, email enabled' => [
84 [],
85 $data = [ 'email' => '', 'realname' => 'Name' ],
86 $data,
87 $unhidden,
88 true
89 ],
90 'email omitted, unhidden, email enabled' => [
91 [],
92 [ 'realname' => 'Name' ],
93 false,
94 $unhidden,
95 true
96 ],
97 'realname empty, unhidden, email enabled' => [
98 [],
99 $data = [ 'email' => 'Email', 'realname' => '' ],
100 $data,
101 $unhidden,
102 true
103 ],
104 'realname omitted, unhidden, email enabled' => [
105 [],
106 [ 'email' => 'Email' ],
107 false,
108 $unhidden,
109 true
110 ],
111 'Empty request, hidden, email enabled' => [
112 [],
113 [],
114 false,
115 $hidden,
116 true
117 ],
118 'email + realname, hidden, email enabled' => [
119 [],
120 [ 'email' => 'Email', 'realname' => 'Name' ],
121 [ 'email' => 'Email' ],
122 $hidden,
123 true
124 ],
125 'email empty, hidden, email enabled' => [
126 [],
127 $data = [ 'email' => '', 'realname' => 'Name' ],
128 [ 'email' => '' ],
129 $hidden,
130 true
131 ],
132 'email omitted, hidden, email enabled' => [
133 [],
134 [ 'realname' => 'Name' ],
135 false,
136 $hidden,
137 true
138 ],
139 'realname empty, hidden, email enabled' => [
140 [],
141 $data = [ 'email' => 'Email', 'realname' => '' ],
142 [ 'email' => 'Email' ],
143 $hidden,
144 true
145 ],
146 'realname omitted, hidden, email enabled' => [
147 [],
148 [ 'email' => 'Email' ],
149 [ 'email' => 'Email' ],
150 $hidden,
151 true
152 ],
153 'email + realname, unhidden, email disabled' => [
154 [],
155 [ 'email' => 'Email', 'realname' => 'Name' ],
156 [ 'realname' => 'Name' ],
157 $unhidden,
158 false
159 ],
160 'email omitted, unhidden, email disabled' => [
161 [],
162 [ 'realname' => 'Name' ],
163 [ 'realname' => 'Name' ],
164 $unhidden,
165 false
166 ],
167 'email empty, unhidden, email disabled' => [
168 [],
169 [ 'email' => '', 'realname' => 'Name' ],
170 [ 'realname' => 'Name' ],
171 $unhidden,
172 false
173 ],
174 ];
175 }
176}
if( $line===false) $args
Definition cdb.php:64
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
AuthManager \MediaWiki\Auth\UserDataAuthenticationRequest.
testLoadFromSubmission(array $args, array $data, $expectState)
provideLoadFromSubmission
testPopulateUser( $email, $realname, $expect)
providePopulateUser
This represents additional user data requested on the account creation form.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition deferred.txt:11
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
this hook is for auditing only $req
Definition hooks.txt:979
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 just before the function returns a value If you return true
Definition hooks.txt:2004
return true to allow those checks to and false if checking is done & $user
Definition hooks.txt:1510
processing should stop and the error should be shown to the user * false
Definition hooks.txt:187
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))