HumHub Documentation (unofficial)

Test
in package
implements AdapterInterface

A testing-purposes adapter.

Should be used to test all components that rely on Laminas\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.

Table of Contents

Interfaces

AdapterInterface
An interface description for Laminas\Http\Client\Adapter classes.

Properties

$config  : array<string|int, mixed>
Parameters array
$nextRequestWillFail  : bool
Whether or not the next request will fail with an exception
$responseIndex  : int
Current position in the response buffer
$responses  : array<string|int, mixed>
Buffer of responses to be returned by the read() method. Can be set using setResponse() and addResponse().

Methods

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

Properties

$config

Parameters array

protected array<string|int, mixed> $config = []

$nextRequestWillFail

Whether or not the next request will fail with an exception

protected bool $nextRequestWillFail = false

$responseIndex

Current position in the response buffer

protected int $responseIndex = 0

$responses

Buffer of responses to be returned by the read() method. Can be set using setResponse() and addResponse().

protected array<string|int, mixed> $responses = ["HTTP/1.1 400 Bad Request\r\n\r\n"]

Methods

__construct()

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

public __construct() : mixed

addResponse()

Add another response to the response buffer.

public addResponse(string|Response $response) : mixed
Parameters
$response : string|Response

close()

Close the connection (dummy)

public close() : mixed

connect()

Connect to the remote server

public connect(string $host[, int $port = 80 ][, bool $secure = false ]) : mixed
Parameters
$host : string
$port : int = 80
$secure : bool = false
Tags
throws
RuntimeException

read()

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

public read() : string
Return values
string

setNextRequestWillFail()

Set the nextRequestWillFail flag

public setNextRequestWillFail(bool $flag) : Test
Parameters
$flag : bool
Return values
Test

setOptions()

Set the configuration array for the adapter

public setOptions([array<string|int, mixed>|Traversable $options = [] ]) : mixed
Parameters
$options : array<string|int, mixed>|Traversable = []
Tags
throws
InvalidArgumentException

setResponse()

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

public setResponse(Response|array<string|int, mixed>|string $response) : mixed
Parameters
$response : Response|array<string|int, mixed>|string

setResponseIndex()

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

public setResponseIndex(int $index) : mixed
Parameters
$index : int
Tags
throws
OutOfRangeException

write()

Send request to the remote server

public write(string $method, Uri $uri[, string $httpVer = '1.1' ][, array<string|int, mixed> $headers = [] ][, string $body = '' ]) : string
Parameters
$method : string
$uri : Uri
$httpVer : string = '1.1'
$headers : array<string|int, mixed> = []
$body : string = ''
Return values
string

Request as string


        
On this page

Search results