14 ->setConstructorArgs( [ [] ] )
15 ->setMethods( [
'isCurlEnabled' ] )->getMock();
16 $client->method(
'isCurlEnabled' )->willReturn(
false );
20 private function getHttpRequest( $statusValue, $statusCode, $headers = [] ) {
22 ->setConstructorArgs( [
'', [] ] )
24 $httpRequest->expects( $this->
any() )
26 ->willReturn( Status::wrap( $statusValue ) );
27 $httpRequest->expects( $this->
any() )
28 ->method(
'getResponseHeaders' )
29 ->willReturn( $headers );
30 $httpRequest->expects( $this->
any() )
31 ->method(
'getStatus' )
32 ->willReturn( $statusCode );
39 $factory->expects( $this->
any() )
41 ->willReturn( $httpRequest );
50 $httpRequest = $this->
getHttpRequest( StatusValue::newGood( 200 ), 200 );
53 list( $rcode, $rdesc, , $rbody, $rerr ) = $this->client->run( [
55 'url' =>
"http://example.test",
67 StatusValue::newFatal(
'http-invalid-url',
'http://www.example.test' ), 0 );
70 list( $rcode, $rdesc, , $rbody, $rerr ) = $this->client->run( [
72 'url' =>
"http://www.example.test",
75 $failure = $rcode < 200 || $rcode >= 400;
84 $httpRequest = $this->
getHttpRequest( StatusValue::newGood( 200 ), 200 );
90 'url' =>
'http://example.test',
94 'url' =>
'https://get.test',
97 $responses = $this->client->runMulti( $reqs );
99 list( $rcode, $rdesc, , $rbody, $rerr ) =
$response[
'response'];
110 StatusValue::newFatal(
"http-bad-status", 404,
'Not Found' ), 404 );
116 'url' =>
'http://example.test/12345',
120 'url' =>
'http://example.test/67890' ,
123 $responses = $this->client->runMulti( $reqs );
125 list( $rcode, $rdesc, , $rbody, $rerr ) =
$response[
'response'];
126 $failure = $rcode < 200 || $rcode >= 400;
138 'text/html; charset=utf-8',
141 'Wed, 18 Jul 2018 14:52:41 GMT',
144 'COUNTRY=NAe6; expires=Wed, 25-Jul-2018 14:52:41 GMT; path=/; domain=.example.test',
145 'LAST_NEWS=1531925562; expires=Thu, 18-Jul-2019 14:52:41 GMT; path=/; domain=.example.test',
150 $httpRequest = $this->
getHttpRequest( StatusValue::newGood( 200 ), 200, $headers );
153 list( $rcode, $rdesc, $rhdrs, $rbody, $rerr ) = $this->client->run( [
155 'url' =>
'http://example.test',
159 $this->
assertEquals( count( $headers ), count( $rhdrs ) );
160 foreach ( $headers as $name => $values ) {
161 $value = implode(
', ', $values );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
Various HTTP related functions.
The urls herein are not actually called, because we mock the return results.
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 hook is for auditing only $response