Zend\Http\Client\Adapter\Test
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.
Synopsis
class Test
implements
AdapterInterface
{
- // members
- protected array $config;
- protected array $responses;
- protected integer $responseIndex;
- protected bool $nextRequestWillFail;
- // methods
- public void __construct()
- public Test setNextRequestWillFail()
- public void setOptions()
- public void connect()
- public string write()
- public string read()
- public void close()
- public void setResponse()
- public void addResponse()
- public void setResponseIndex()
Hierarchy
Implements
Members
protected
- $config
—
array
Parameters array - $nextRequestWillFail
—
Zend\Http\Client\Adapter\bool
Whether or not the next request will fail with an exception - $responseIndex
—
int
Current position in the response buffer - $responses
—
array
Buffer of responses to be returned by the read() method. Can be set using setResponse() and addResponse().
Methods
public
- __construct() — Adapter constructor, currently empty. Config is set using setOptions()
- addResponse() — Add another response to the response buffer.
- close() — Close the connection (dummy)
- connect() — Connect to the remote server
- read() — Return the response set in $this->setResponse()
- setNextRequestWillFail() — Set the nextRequestWillFail flag
- setOptions() — Set the configuration array for the adapter
- setResponse() — Set the HTTP response(s) to be returned by this adapter
- setResponseIndex() — Sets the position of the response buffer. Selects which response will be returned on the next call to read().
- write() — Send request to the remote server