Nexus API Reference

TestResponse
in package

Read onlyYes
FinalYes
Tags
psalm-api

PSR-7 ResponseInterface decorator with fluent test assertions. Each assert* method returns $this for chaining; access the raw response via psr() if you need to inspect anything outside this shorthand surface.

All assertions use PHPUnit\Framework\Assert directly, so failures appear in the test output like any other PHPUnit assertion.

Table of Contents

Methods

__construct()  : mixed
assertBadRequest()  : self
assertBodyContains()  : self
assertCreated()  : self
assertForbidden()  : self
assertHeader()  : self
assertHeaderExists()  : self
assertJsonHasKey()  : self
assertJsonPath()  : self
Assert a dot-path value in the JSON body.
assertNoContent()  : self
assertNotFound()  : self
assertOk()  : self
assertRedirectsTo()  : self
assertServerError()  : self
assertStatus()  : self
assertUnauthorized()  : self
body()  : string
header()  : string
json()  : array<string|int, mixed>
psr()  : ResponseInterface
status()  : int

Methods

__construct()

public __construct(ResponseInterface $response) : mixed
Parameters
$response : ResponseInterface

assertBadRequest()

public assertBadRequest() : self
Return values
self

assertBodyContains()

public assertBodyContains(string $needle) : self
Parameters
$needle : string
Return values
self

assertCreated()

public assertCreated() : self
Return values
self

assertForbidden()

public assertForbidden() : self
Return values
self

assertHeader()

public assertHeader(string $name, string $expected) : self
Parameters
$name : string
$expected : string
Return values
self

assertHeaderExists()

public assertHeaderExists(string $name) : self
Parameters
$name : string
Return values
self

assertJsonHasKey()

public assertJsonHasKey(string $path) : self
Parameters
$path : string
Return values
self

assertJsonPath()

Assert a dot-path value in the JSON body.

public assertJsonPath(string $path, mixed $expected) : self

$response->assertJsonPath('user.id', 42);

Parameters
$path : string
$expected : mixed
Return values
self

assertNoContent()

public assertNoContent() : self
Return values
self

assertNotFound()

public assertNotFound() : self
Return values
self

assertRedirectsTo()

public assertRedirectsTo(string $location) : self
Parameters
$location : string
Return values
self

assertServerError()

public assertServerError() : self
Return values
self

assertStatus()

public assertStatus(int $expected) : self
Parameters
$expected : int
Return values
self

assertUnauthorized()

public assertUnauthorized() : self
Return values
self

header()

public header(string $name) : string
Parameters
$name : string
Return values
string

json()

public json() : array<string|int, mixed>
Return values
array<string|int, mixed>

psr()

public psr() : ResponseInterface
Return values
ResponseInterface

        
On this page

Search results