16 ->setConstructorArgs( [ [] ] )
17 ->setMethods( [
'isCurlEnabled' ] )->getMock();
18 $client->method(
'isCurlEnabled' )->willReturn(
false );
22 private function getHttpRequest( $statusValue, $statusCode, $headers = [] ) {
24 ->setConstructorArgs( [
'', [] ] )
26 $httpRequest->expects( $this->
any() )
29 $httpRequest->expects( $this->
any() )
30 ->method(
'getResponseHeaders' )
31 ->willReturn( $headers );
32 $httpRequest->expects( $this->
any() )
33 ->method(
'getStatus' )
34 ->willReturn( $statusCode );
41 $factory->expects( $this->
any() )
43 ->willReturn( $httpRequest );
55 list( $rcode, $rdesc, , $rbody, $rerr ) = $this->client->run( [
57 'url' =>
"http://example.test",
60 $this->assertEquals( 200, $rcode );
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 );
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 );
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',
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 );