A testing-purposes adapter.

Should be used to test all components that rely on Zend_Http_Client, without actually performing an HTTP request. You should instantiate this object manually, and then set it as the client's adapter. Then, you can set the expected response using the setResponse() method.

 Methods

Adapter constructor, currently empty.

__construct() 

Config is set using setOptions()

Add another response to the response buffer.

addResponse(string | \Zend\Http\Response $response) 

Parameters

$response

string\Zend\Http\Response

Close the connection (dummy)

close() 

Connect to the remote server

connect(string $host, int $port, bool $secure) 

Parameters

$host

string

$port

int

$secure

bool

Exceptions

\Zend\Http\Client\Adapter\Exception\RuntimeException

Return the response set in $this->setResponse()

read() : string

Returns

string

Set the nextRequestWillFail flag

setNextRequestWillFail(bool $flag) : \Zend\Http\Client\Adapter\Test

Parameters

$flag

bool

Returns

Set the configuration array for the adapter

setOptions(array | \Traversable $options) 

Parameters

$options

array\Traversable

Exceptions

\Zend\Http\Client\Adapter\Exception\InvalidArgumentException

Set the HTTP response(s) to be returned by this adapter

setResponse(\Zend\Http\Response | array | string $response) 

Parameters

$response

\Zend\Http\Responsearraystring

Sets the position of the response buffer.

setResponseIndex(integer $index) 

Selects which response will be returned on the next call to read().

Parameters

$index

integer

Exceptions

\Zend\Http\Client\Adapter\Exception\OutOfRangeException

Send request to the remote server

write(string $method, \Zend\Uri\Uri $uri, string $httpVer, array $headers, string $body) : string

Parameters

$method

string

$httpVer

string

$headers

array

$body

string

Returns

stringRequest as string

 Properties

 

Parameters array

$config : array

 

Whether or not the next request will fail with an exception

$nextRequestWillFail : bool

 

Current position in the response buffer

$responseIndex : integer

 

Buffer of responses to be returned by the read() method.

$responses : array

Can be set using setResponse() and addResponse().