CodeIgniter v4.5 API

TestResponse
in package

Consolidated response processing for test results.

Tags
mixin

DOMParser

see
TestResponseTest

Table of Contents

Properties

$domParser  : DOMParser
DOM for the body.
$request  : RequestInterface|null
The request.
$response  : ResponseInterface
The response.

Methods

__call()  : mixed
Forward any unrecognized method calls to our DOMParser instance.
__construct()  : mixed
Stores or the Response and parses the body in the DOM.
assertCookie()  : void
Asserts that the response has the specified cookie.
assertCookieExpired()  : void
Asserts that a cookie exists and has an expired time.
assertCookieMissing()  : void
Assert the Response does not have the specified cookie set.
assertDontSee()  : void
Asserts that we do not see the specified text.
assertDontSeeElement()  : void
Assert that we do not see an element selected via a CSS selector.
assertHeader()  : void
Asserts that the Response contains a specific header.
assertHeaderMissing()  : void
Asserts the Response headers does not contain the specified header.
assertJSONExact()  : void
Asserts that the JSON exactly matches the passed in data.
assertJSONFragment()  : void
Test that the response contains a matching JSON fragment.
assertNotOK()  : void
Asserts that the Response is considered not OK.
assertNotRedirect()  : void
Assert that the given response was not a redirect.
assertOK()  : void
Asserts that the Response is considered OK.
assertRedirect()  : void
Assert that the given response was a redirect.
assertRedirectTo()  : void
Assert that a given response was a redirect and it was redirect to a specific URI.
assertSee()  : void
Assert that the desired text can be found in the result body.
assertSeeElement()  : void
Assert that we see an element selected via a CSS selector.
assertSeeInField()  : void
Assert that we see an input with name/value.
assertSeeLink()  : void
Assert that we see a link with the matching text and/or class.
assertSessionHas()  : void
Asserts that an SESSION key has been set and, optionally, test its value.
assertSessionMissing()  : void
Asserts the session is missing $key.
assertStatus()  : void
Asserts that the status is a specific value.
getJSON()  : false|string
Returns the response's body as JSON
getRedirectUrl()  : string|null
Returns the URL set for redirection.
getXML()  : bool|string|null
Returns the response' body as XML
isOK()  : bool
Boils down the possible responses into a boolean valid/not-valid response type.
isRedirect()  : bool
Returns whether or not the Response was a redirect or RedirectResponse
request()  : RequestInterface|null
Request accessor.
response()  : ResponseInterface
Response accessor.
setRequest()  : $this
Sets the request.
setResponse()  : $this
Sets the Response and updates the DOM.

Properties

Methods

__call()

Forward any unrecognized method calls to our DOMParser instance.

public __call(string $function, array<int, mixed> $params) : mixed
Parameters
$function : string
$params : array<int, mixed>

assertCookie()

Asserts that the response has the specified cookie.

public assertCookie(string $key[, string|null $value = null ][, string $prefix = '' ]) : void
Parameters
$key : string
$value : string|null = null
$prefix : string = ''

assertCookieExpired()

Asserts that a cookie exists and has an expired time.

public assertCookieExpired(string $key[, string $prefix = '' ]) : void
Parameters
$key : string
$prefix : string = ''

assertCookieMissing()

Assert the Response does not have the specified cookie set.

public assertCookieMissing(string $key) : void
Parameters
$key : string

assertDontSee()

Asserts that we do not see the specified text.

public assertDontSee([string|null $search = null ][, string|null $element = null ]) : void
Parameters
$search : string|null = null
$element : string|null = null

assertDontSeeElement()

Assert that we do not see an element selected via a CSS selector.

public assertDontSeeElement(string $search) : void
Parameters
$search : string

assertHeader()

Asserts that the Response contains a specific header.

public assertHeader(string $key[, string|null $value = null ]) : void
Parameters
$key : string
$value : string|null = null

assertHeaderMissing()

Asserts the Response headers does not contain the specified header.

public assertHeaderMissing(string $key) : void
Parameters
$key : string

assertJSONExact()

Asserts that the JSON exactly matches the passed in data.

public assertJSONExact(array<string|int, mixed>|object|string $test) : void

If the value being passed in is a string, it must be a json_encoded string.

Parameters
$test : array<string|int, mixed>|object|string

assertJSONFragment()

Test that the response contains a matching JSON fragment.

public assertJSONFragment(array<string|int, mixed> $fragment[, bool $strict = false ]) : void
Parameters
$fragment : array<string|int, mixed>
$strict : bool = false

assertNotOK()

Asserts that the Response is considered not OK.

public assertNotOK() : void

assertNotRedirect()

Assert that the given response was not a redirect.

public assertNotRedirect() : void

assertOK()

Asserts that the Response is considered OK.

public assertOK() : void

assertRedirect()

Assert that the given response was a redirect.

public assertRedirect() : void

assertRedirectTo()

Assert that a given response was a redirect and it was redirect to a specific URI.

public assertRedirectTo(string $uri) : void
Parameters
$uri : string

assertSee()

Assert that the desired text can be found in the result body.

public assertSee([string|null $search = null ][, string|null $element = null ]) : void
Parameters
$search : string|null = null
$element : string|null = null

assertSeeElement()

Assert that we see an element selected via a CSS selector.

public assertSeeElement(string $search) : void
Parameters
$search : string

assertSeeInField()

Assert that we see an input with name/value.

public assertSeeInField(string $field[, string|null $value = null ]) : void
Parameters
$field : string
$value : string|null = null

Assert that we see a link with the matching text and/or class.

public assertSeeLink(string $text[, string|null $details = null ]) : void
Parameters
$text : string
$details : string|null = null

assertSessionHas()

Asserts that an SESSION key has been set and, optionally, test its value.

public assertSessionHas(string $key[, mixed $value = null ]) : void
Parameters
$key : string
$value : mixed = null

assertSessionMissing()

Asserts the session is missing $key.

public assertSessionMissing(string $key) : void
Parameters
$key : string

assertStatus()

Asserts that the status is a specific value.

public assertStatus(int $code) : void
Parameters
$code : int

getJSON()

Returns the response's body as JSON

public getJSON() : false|string
Return values
false|string

getRedirectUrl()

Returns the URL set for redirection.

public getRedirectUrl() : string|null
Return values
string|null

getXML()

Returns the response' body as XML

public getXML() : bool|string|null
Return values
bool|string|null

isOK()

Boils down the possible responses into a boolean valid/not-valid response type.

public isOK() : bool
Return values
bool

isRedirect()

Returns whether or not the Response was a redirect or RedirectResponse

public isRedirect() : bool
Return values
bool

        
On this page

Search results