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)

Sends an HTTP request and returns an HttpAssert instance for chaining assertions.

expectCode(int|Closure $expected)

Asserts that the HTTP response code matches the expectation.

denyCode(int|Closure $expected)

Asserts that the HTTP response code does not match the expectation.

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

Asserts that a response header exists and optionally matches the expectation.

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

Asserts that a response header does not exist or does not match the expectation.

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

Asserts that the response body matches the expectation.

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

Asserts that the response body does not match the expectation.

Details

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

Sends an HTTP request and returns an HttpAssert instance for chaining assertions.

Parameters

string $url
string $method
array $headers

headers as 'Name: Value' strings or name => value pairs

array $cookies

cookie name => value pairs

bool $follow
string|null $body

Return Value

HttpAssert

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

Asserts that the HTTP response code matches the expectation.

Parameters

int|Closure $expected

Return Value

HttpAssert

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

Asserts that the HTTP response code does not match the expectation.

Parameters

int|Closure $expected

Return Value

HttpAssert

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

Asserts that a response header exists and optionally matches the expectation.

Parameters

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

Return Value

HttpAssert

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

Asserts that a response header does not exist or does not match the expectation.

Parameters

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

Return Value

HttpAssert

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

Asserts that the response body matches the expectation.

Parameters

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

Return Value

HttpAssert

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

Asserts that the response body does not match the expectation.

Parameters

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

Return Value

HttpAssert