15 $client = $this->getMockBuilder( MultiHttpClient::class )
16 ->setConstructorArgs( [ [] ] )
17 ->setMethods( [
'isCurlEnabled' ] )->getMock();
18 $client->method(
'isCurlEnabled' )->willReturn(
false );
22 private function getHttpRequest( $statusValue, $statusCode, $headers = [] ) {
23 $httpRequest = $this->getMockBuilder( PhpHttpRequest::class )
24 ->setConstructorArgs( [
'', [] ] )
26 $httpRequest->expects( $this->any() )
28 ->willReturn( Status::wrap( $statusValue ) );
29 $httpRequest->expects( $this->any() )
30 ->method(
'getResponseHeaders' )
31 ->willReturn( $headers );
32 $httpRequest->expects( $this->any() )
33 ->method(
'getStatus' )
34 ->willReturn( $statusCode );
39 $factory = $this->getMockBuilder(
MediaWiki\
Http\HttpRequestFactory::class )
41 $factory->expects( $this->any() )
43 ->willReturn( $httpRequest );
52 $httpRequest = $this->
getHttpRequest( StatusValue::newGood( 200 ), 200 );
55 list( $rcode, $rdesc, , $rbody, $rerr ) = $this->client->run( [
57 'url' =>
"http://example.test",
60 $this->assertEquals( 200, $rcode );
69 StatusValue::newFatal(
'http-invalid-url',
'http://www.example.test' ), 0 );
72 list( $rcode, $rdesc, , $rbody, $rerr ) = $this->client->run( [
74 'url' =>
"http://www.example.test",
77 $failure = $rcode < 200 || $rcode >= 400;
78 $this->assertTrue( $failure );
86 $httpRequest = $this->
getHttpRequest( StatusValue::newGood( 200 ), 200 );
92 'url' =>
'http://example.test',
96 'url' =>
'https://get.test',
99 $responses = $this->client->runMulti( $reqs );
101 list( $rcode, $rdesc, , $rbody, $rerr ) =
$response[
'response'];
102 $this->assertEquals( 200, $rcode );
112 StatusValue::newFatal(
"http-bad-status", 404,
'Not Found' ), 404 );
118 'url' =>
'http://example.test/12345',
122 'url' =>
'http://example.test/67890' ,
125 $responses = $this->client->runMulti( $reqs );
127 list( $rcode, $rdesc, , $rbody, $rerr ) =
$response[
'response'];
128 $failure = $rcode < 200 || $rcode >= 400;
129 $this->assertTrue( $failure );
140 'text/html; charset=utf-8',
143 'Wed, 18 Jul 2018 14:52:41 GMT',
146 'COUNTRY=NAe6; expires=Wed, 25-Jul-2018 14:52:41 GMT; path=/; domain=.example.test',
147 'LAST_NEWS=1531925562; expires=Thu, 18-Jul-2019 14:52:41 GMT; path=/; domain=.example.test',
152 $httpRequest = $this->
getHttpRequest( StatusValue::newGood( 200 ), 200, $headers );
155 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->client->run( [
157 'url' =>
'http://example.test',
160 $this->assertEquals( 200, $rcode );
161 $this->assertEquals( count( $headers ), count( $rhdrs ) );
162 foreach ( $headers
as $name => $values ) {
163 $value = implode(
', ', $values );
164 $this->assertArrayHasKey(
$name, $rhdrs );
Various HTTP related functions.
Tests for MultiHttpClient.
testMultiHttpClientMultipleSuccess()
Test call of multiple urls that should all succeed.
testMultiHttpClientSingleFailure()
Test call of a single url that should not exist, and therefore fail.
testMultiHttpClientSingleSuccess()
Test call of a single url that should succeed.
mockHttpRequestFactory( $httpRequest)
testMultiHttpClientHeaders()
Test of response header handling.
getHttpRequest( $statusValue, $statusCode, $headers=[])
testMultiHttpClientMultipleFailure()
Test call of multiple urls that should all fail.
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
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
Allows to change the fields on the form that will be generated $name
this hook is for auditing only $response
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