11 $mock = $this->getMockForAbstractClass( AuthenticationRequest::class );
13 $this->assertSame( get_class( $mock ), $mock->getUniqueId() );
15 $this->
assertType(
'array', $mock->getMetadata() );
17 $ret = $mock->describeCredentials();
18 $this->assertInternalType(
'array',
$ret );
19 $this->assertArrayHasKey(
'provider',
$ret );
20 $this->assertInstanceOf( \Message::class,
$ret[
'provider'] );
21 $this->assertArrayHasKey(
'account',
$ret );
22 $this->assertInstanceOf( \Message::class,
$ret[
'account'] );
26 $mb = $this->getMockBuilder( AuthenticationRequest::class )
27 ->setMethods( [
'loadFromSubmission' ] );
29 $data = [
'foo',
'bar' ];
31 $req1 = $mb->getMockForAbstractClass();
32 $req1->expects( $this->once() )->method(
'loadFromSubmission' )
33 ->with( $this->identicalTo(
$data ) )
34 ->will( $this->returnValue(
false ) );
36 $req2 = $mb->getMockForAbstractClass();
37 $req2->expects( $this->once() )->method(
'loadFromSubmission' )
38 ->with( $this->identicalTo(
$data ) )
39 ->will( $this->returnValue(
true ) );
48 $mb = $this->getMockBuilder(
49 AuthenticationRequest::class,
'AuthenticationRequestTest_AuthenticationRequest2'
53 $this->getMockForAbstractClass(
54 AuthenticationRequest::class, [],
'AuthenticationRequestTest_AuthenticationRequest1'
56 $mb->getMockForAbstractClass(),
57 $mb->getMockForAbstractClass(),
58 $this->getMockForAbstractClass(
59 PasswordAuthenticationRequest::class, [],
60 'AuthenticationRequestTest_PasswordAuthenticationRequest'
65 $reqs,
'AuthenticationRequestTest_AuthenticationRequest0'
68 $reqs,
'AuthenticationRequestTest_AuthenticationRequest1'
71 $reqs,
'AuthenticationRequestTest_AuthenticationRequest2'
74 $reqs, PasswordAuthenticationRequest::class
77 $reqs,
'ClassThatDoesNotExist'
81 $reqs,
'AuthenticationRequestTest_AuthenticationRequest0',
true
84 $reqs,
'AuthenticationRequestTest_AuthenticationRequest1',
true
87 $reqs,
'AuthenticationRequestTest_AuthenticationRequest2',
true
90 $reqs, PasswordAuthenticationRequest::class,
true
93 $reqs,
'ClassThatDoesNotExist',
true
98 $mb = $this->getMockBuilder( AuthenticationRequest::class );
100 for ( $i = 0; $i < 3; $i++ ) {
101 $req = $mb->getMockForAbstractClass();
102 $req->expects( $this->any() )->method(
'getFieldInfo' )->will( $this->returnValue( [
110 $req = $mb->getMockForAbstractClass();
111 $req->expects( $this->any() )->method(
'getFieldInfo' )->will( $this->returnValue( [] ) );
112 $req->username =
'baz';
117 $reqs[1]->username =
'foo';
120 $reqs[0]->username =
'foo';
121 $reqs[2]->username =
'foo';
124 $reqs[1]->username =
'bar';
127 $this->fail(
'Expected exception not thrown' );
128 }
catch ( \UnexpectedValueException $ex ) {
130 'Conflicting username fields: "bar" from ' .
131 get_class( $reqs[1] ) .
'::$username vs. "foo" from ' .
132 get_class( $reqs[0] ) .
'::$username',
141 $req1 = $this->createMock( AuthenticationRequest::class );
143 $req1->expects( $this->any() )->method(
'getFieldInfo' )->will( $this->returnValue( [
162 'options' => [
'foo' => $msg,
'baz' => $msg ],
168 $req2 = $this->createMock( AuthenticationRequest::class );
170 $req2->expects( $this->any() )->method(
'getFieldInfo' )->will( $this->returnValue( [
184 'options' => [
'bar' => $msg,
'baz' => $msg ],
190 $req3 = $this->createMock( AuthenticationRequest::class );
192 $req3->expects( $this->any() )->method(
'getFieldInfo' )->will( $this->returnValue( [
194 'type' =>
'checkbox',
200 $req4 = $this->createMock( AuthenticationRequest::class );
202 $req4->expects( $this->any() )->method(
'getFieldInfo' )->will( $this->returnValue( [] ) );
207 $expect = $req1->getFieldInfo();
213 $this->assertEquals( $expect, $fields );
216 $this->assertEquals( $expect, $fields );
220 $this->fail(
'Expected exception not thrown' );
221 }
catch ( \UnexpectedValueException $ex ) {
223 'Field type conflict for "string1", "string" vs "checkbox"',
229 $expect += $req2->getFieldInfo();
230 $expect[
'string1'][
'sensitive'] =
true;
231 $expect[
'string2'][
'optional'] =
false;
232 $expect[
'string3'][
'optional'] =
false;
233 $expect[
'string3'][
'sensitive'] =
false;
234 $expect[
'select'][
'options'][
'bar'] = $msg;
235 $this->assertEquals( $expect, $fields );
242 $expect += $req2->getFieldInfo();
243 $expect[
'string1'][
'optional'] =
false;
244 $expect[
'string1'][
'sensitive'] =
true;
245 $expect[
'string3'][
'optional'] =
false;
246 $expect[
'select'][
'optional'] =
false;
247 $expect[
'select'][
'options'][
'bar'] = $msg;
248 $this->assertEquals( $expect, $fields );
253 $expect = $req1->getFieldInfo() + $req2->getFieldInfo();
257 $expect[
'string1'][
'optional'] =
false;
258 $expect[
'string1'][
'sensitive'] =
true;
259 $expect[
'string2'][
'optional'] =
true;
260 $expect[
'string3'][
'optional'] =
true;
261 $expect[
'select'][
'optional'] =
false;
262 $expect[
'select'][
'options'][
'bar'] = $msg;
263 $this->assertEquals( $expect, $fields );
273 $mock = $this->getMockForAbstractClass( AuthenticationRequest::class );
274 $mock->expects( $this->any() )->method(
'getFieldInfo' )
275 ->will( $this->returnValue( $fieldInfo ) );
277 $ret = $mock->loadFromSubmission(
$data );
278 if ( is_array( $expectState ) ) {
279 $this->assertTrue(
$ret );
280 $expect = call_user_func( [ get_class( $mock ),
'__set_state' ], $expectState );
281 $this->assertEquals( $expect, $mock );
283 $this->assertFalse(
$ret );
291 $data = [
'foo' =>
'bar' ],
301 $data = [
'field' =>
'string!' ],
304 'Simple field, not supplied' => [
313 'Simple field, empty' => [
322 'Simple field, optional, not supplied' => [
332 'Simple field, optional, empty' => [
339 $data = [
'field' =>
'' ],
343 'Checkbox, checked' => [
346 'type' =>
'checkbox',
352 'Checkbox, unchecked' => [
355 'type' =>
'checkbox',
361 'Checkbox, optional, unchecked' => [
364 'type' =>
'checkbox',
381 'Button, unused' => [
390 'Button, optional, unused' => [
400 'Button, image-style' => [
406 [
'push_x' => 0,
'push_y' => 0 ],
420 $data = [
'choose' =>
'foo' ],
423 'Select, invalid choice' => [
433 $data = [
'choose' =>
'baz' ],
436 'Multiselect (2)' => [
439 'type' =>
'multiselect',
446 $data = [
'choose' => [
'foo',
'bar' ] ],
449 'Multiselect (1)' => [
452 'type' =>
'multiselect',
459 $data = [
'choose' => [
'bar' ] ],
462 'Multiselect, string for some reason' => [
465 'type' =>
'multiselect',
472 [
'choose' =>
'foo' ],
473 [
'choose' => [
'foo' ] ]
475 'Multiselect, invalid choice' => [
478 'type' =>
'multiselect',
485 [
'choose' => [
'foo',
'baz' ] ],
488 'Multiselect, empty' => [
491 'type' =>
'multiselect',
501 'Multiselect, optional, nothing submitted' => [
504 'type' =>
'multiselect',
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
this hook is for auditing only $req
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 & $options
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
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
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
Allows to change the fields on the form that will be generated $name
processing should stop and the error should be shown to the user * false
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