class HttpAssert

HTTP testing helpers.

Methods

static HttpAssert
fetch(string $url, string $method = 'GET', array $headers = [], array $cookies = [], bool $follow = false, string|null $body = null)

Creates HTTP request, executes it and returns HttpTest instance for chaining expectations.

expectCode(int|Closure $expected)

Asserts HTTP response code matches expectation.

denyCode(int|Closure $expected)

Asserts HTTP response code does not match expectation.

expectHeader(string $name, string|Closure|null $expected = null, string|null $contains = null, string|null $matches = null)

Asserts HTTP response header matches expectation.

denyHeader(string $name, string|Closure|null $expected = null, string|null $contains = null, string|null $matches = null)

Asserts HTTP response header does not match expectation.

expectBody(string|Closure|null $expected = null, string|null $contains = null, string|null $matches = null)

Asserts HTTP response body matches expectation.

denyBody(string|Closure|null $expected = null, string|null $contains = null, string|null $matches = null)

Asserts HTTP response body does not match expectation.

Details

at line 31
static HttpAssert fetch(string $url, string $method = 'GET', array $headers = [], array $cookies = [], bool $follow = false, string|null $body = null)

Creates HTTP request, executes it and returns HttpTest instance for chaining expectations.

Parameters

string $url
string $method
array $headers
array $cookies
bool $follow
string|null $body

Return Value

HttpAssert

at line 98
HttpAssert expectCode(int|Closure $expected)

Asserts HTTP response code matches expectation.

Parameters

int|Closure $expected

Return Value

HttpAssert

at line 113
HttpAssert denyCode(int|Closure $expected)

Asserts HTTP response code does not match expectation.

Parameters

int|Closure $expected

Return Value

HttpAssert

at line 128
HttpAssert expectHeader(string $name, string|Closure|null $expected = null, string|null $contains = null, string|null $matches = null)

Asserts HTTP response header matches expectation.

Parameters

string $name
string|Closure|null $expected
string|null $contains
string|null $matches

Return Value

HttpAssert

at line 155
HttpAssert denyHeader(string $name, string|Closure|null $expected = null, string|null $contains = null, string|null $matches = null)

Asserts HTTP response header does not match expectation.

Parameters

string $name
string|Closure|null $expected
string|null $contains
string|null $matches

Return Value

HttpAssert

at line 186
HttpAssert expectBody(string|Closure|null $expected = null, string|null $contains = null, string|null $matches = null)

Asserts HTTP response body matches expectation.

Parameters

string|Closure|null $expected
string|null $contains
string|null $matches

Return Value

HttpAssert

at line 209
HttpAssert denyBody(string|Closure|null $expected = null, string|null $contains = null, string|null $matches = null)

Asserts HTTP response body does not match expectation.

Parameters

string|Closure|null $expected
string|null $contains
string|null $matches

Return Value

HttpAssert