Nexus API Reference

HttpTestClient
in package

FinalYes
Tags
psalm-api

In-process test client for Nexus HTTP applications. Builds a PSR-7 ServerRequest, dispatches it through the CompiledApplication, and returns a TestResponse for fluent assertions — no socket, no Swoole.

Drop-in for unit and integration tests:

$app = HttpApplication::create($system) ->get('/orders/{id}', ShowOrderHandler::class) ->compile();

$response = HttpTestClient::for($app) ->withHeader('Authorization', 'Bearer xyz') ->get('/orders/42');

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

Pair with StepRuntime for fully deterministic test runs: the actor system runs step()/drain() between assertions, so request handling doesn't depend on wall-clock or fiber scheduling.

Table of Contents

Methods

delete()  : TestResponse
for()  : self
get()  : TestResponse
patch()  : TestResponse
post()  : TestResponse
put()  : TestResponse
withBase()  : self
withBearerToken()  : self
withCookie()  : self
withHeader()  : self

Methods

delete()

public delete(string $path[, array<string, scalar|null> $query = [] ]) : TestResponse
Parameters
$path : string
$query : array<string, scalar|null> = []
Return values
TestResponse

get()

public get(string $path[, array<string, scalar|null> $query = [] ]) : TestResponse
Parameters
$path : string
$query : array<string, scalar|null> = []
Return values
TestResponse

patch()

public patch(string $path[, array<string, mixed>|string|null $body = null ]) : TestResponse
Parameters
$path : string
$body : array<string, mixed>|string|null = null
Return values
TestResponse

post()

public post(string $path[, array<string, mixed>|string|null $body = null ]) : TestResponse
Parameters
$path : string
$body : array<string, mixed>|string|null = null
Return values
TestResponse

put()

public put(string $path[, array<string, mixed>|string|null $body = null ]) : TestResponse
Parameters
$path : string
$body : array<string, mixed>|string|null = null
Return values
TestResponse

withBase()

public withBase(string $scheme, string $host) : self
Parameters
$scheme : string
$host : string
Return values
self

withBearerToken()

public withBearerToken(string $token) : self
Parameters
$token : string
Return values
self

withCookie()

public withCookie(string $name, string $value) : self
Parameters
$name : string
$value : string
Return values
self

withHeader()

public withHeader(string $name, string $value) : self
Parameters
$name : string
$value : string
Return values
self

        
On this page

Search results