Class Test

Summary

Fully Qualified Name: Zend\Http\Client\Adapter\Test
Implements: AdapterInterface

Description

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

Name Description Defined By
__construct() Adapter constructor, currently empty. Config is set using setOptions() Test
addResponse() Add another response to the response buffer. Test
close() Close the connection (dummy) Test
connect() Connect to the remote server Test
read() Return the response set in $this->setResponse() Test
setNextRequestWillFail() Set the nextRequestWillFail flag Test
setOptions() Set the configuration array for the adapter Test
setResponse() Set the HTTP response(s) to be returned by this adapter Test
setResponseIndex() Sets the position of the response buffer. Selects which response will be returned on the next call to read(). Test
write() Send request to the remote server Test

Method Details

__construct()

Adapter constructor, currently empty. Config is set using setOptions()

Returns:

addResponse()

Add another response to the response buffer.

Parameter Name Type Description
$response string|\Response

Returns:

close()

Close the connection (dummy)

Returns:

connect()

Connect to the remote server

Parameter Name Type Description
$host string
$port int
$secure bool

Returns:

read()

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

Returns: string

setNextRequestWillFail()

Set the nextRequestWillFail flag

Parameter Name Type Description
$flag bool

Returns: \Zend\Http\Client\Adapter\Test

setOptions()

Set the configuration array for the adapter

Parameter Name Type Description
$options array|\Traversable

Returns:

setResponse()

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

Parameter Name Type Description
$response \Zend\Http\Response|array|string

Returns:

setResponseIndex()

Sets the position of the response buffer. Selects which response will be returned on the next call to read().

Parameter Name Type Description
$index int

Returns:

write()

Send request to the remote server

Parameter Name Type Description
$method string
$uri \Zend\Uri\Uri
$httpVer string
$headers array
$body string

Returns: string Request as string

Top