API Index — Namespaces, Packages, Reports, Indices
Tester
in package
Drive a reactive component in a unit test, without a server or a browser:
Tester::render(Counter::class, ['count' => 1]) ->call('add', ['by' => 2]) ->assertSet('count', 3) ->assertSee('3');
Each step goes through the real component endpoint with the plain-HTTP
protocol (Zeal-Request: 1), so snapshots, validation, authorize(),
hooks, events and redirects behave exactly as in production. Assertions
use PHPUnit when it's installed and throw \AssertionError otherwise.
Without ZEALPHP_APP_KEY the tester uses a random key for the process.
Table of Contents
Properties
Methods
- assertDispatched() : self
- assertDontSee() : self
- assertHasErrors() : self
- Every named field has an error; with none named, at least one error exists.
- assertHasNoErrors() : self
- assertRedirect() : self
- assertSee() : self
- The markup contains $text (HTML-escaped first, unless $escape is false).
- assertSet() : self
- assertStatus() : self
- call() : self
- Run an
#[Action], like clicking its button. - errors() : array<string, string>
- events() : array<string, mixed>
- get() : mixed
- A public property's current value.
- html() : string
- The component's current markup (its outer element included).
- redirectedTo() : string|null
- Where the last step redirected the page, or null.
- refresh() : self
- Re-render with the current state, like a push refresh.
- render() : self
- Render a component (registering its class if needed).
- set() : self
- Change a
#[Model]property, like typing into its input: the field is validated and itsupdated{Prop}()hook runs. The other bound fields are sent with their current values, as a browser would. - status() : int
- HTTP status of the last step (200 before any).
- __construct() : mixed
- check() : self
- currentFields() : array<string, mixed>
- The bound fields' current values, encoded as a form would send them.
- field() : array<string, mixed>
- instance() : Component
- send() : self
- snapshot() : Snapshot
- wire() : string
Properties
$body
private
string
$body
= ''
$headers
private
array<string, string>
$headers
= []
$html
private
string
$html
$meta read-only
private
ComponentMeta
$meta
$status
private
int
$status
= 200
Methods
assertDispatched()
public
assertDispatched(string $event) : self
Parameters
- $event : string
Return values
selfassertDontSee()
public
assertDontSee(string $text[, bool $escape = true ]) : self
Parameters
- $text : string
- $escape : bool = true
Return values
selfassertHasErrors()
Every named field has an error; with none named, at least one error exists.
public
assertHasErrors(string ...$fields) : self
Parameters
- $fields : string
Return values
selfassertHasNoErrors()
public
assertHasNoErrors() : self
Return values
selfassertRedirect()
public
assertRedirect([string|null $to = null ]) : self
Parameters
- $to : string|null = null
Return values
selfassertSee()
The markup contains $text (HTML-escaped first, unless $escape is false).
public
assertSee(string $text[, bool $escape = true ]) : self
Parameters
- $text : string
- $escape : bool = true
Return values
selfassertSet()
public
assertSet(string $prop, mixed $expected) : self
Parameters
- $prop : string
- $expected : mixed
Return values
selfassertStatus()
public
assertStatus(int $status) : self
Parameters
- $status : int
Return values
selfcall()
Run an #[Action], like clicking its button.
public
call(string $action[, array<string, mixed> $args = [] ]) : self
Parameters
- $action : string
- $args : array<string, mixed> = []
Return values
selferrors()
public
errors() : array<string, string>
Return values
array<string, string> —field → message
events()
public
events() : array<string, mixed>
Return values
array<string, mixed> —events the last step dispatched, name → detail
get()
A public property's current value.
public
get(string $prop) : mixed
Parameters
- $prop : string
html()
The component's current markup (its outer element included).
public
html() : string
Return values
stringredirectedTo()
Where the last step redirected the page, or null.
public
redirectedTo() : string|null
Return values
string|nullrefresh()
Re-render with the current state, like a push refresh.
public
refresh() : self
Return values
selfrender()
Render a component (registering its class if needed).
public
static render(Component>|string $component[, array<string, mixed> $props = [] ][, string|null $key = null ]) : self
Parameters
- $component : Component>|string
-
a class or a registered name
- $props : array<string, mixed> = []
- $key : string|null = null
Return values
selfset()
Change a #[Model] property, like typing into its input: the field is
validated and its updated{Prop}() hook runs. The other bound fields
are sent with their current values, as a browser would.
public
set(string $prop, mixed $value) : self
Parameters
- $prop : string
- $value : mixed
Return values
selfstatus()
HTTP status of the last step (200 before any).
public
status() : int
Return values
int__construct()
private
__construct(ComponentMeta $meta) : mixed
Parameters
- $meta : ComponentMeta
check()
private
check(bool $ok, string $message) : self
Parameters
- $ok : bool
- $message : string
Return values
selfcurrentFields()
The bound fields' current values, encoded as a form would send them.
private
currentFields() : array<string, mixed>
Return values
array<string, mixed>field()
private
static field(string $prop, mixed $value) : array<string, mixed>
Parameters
- $prop : string
- $value : mixed
Return values
array<string, mixed>instance()
private
instance() : Component
Return values
Componentsend()
private
send(string $action, array<string, mixed> $fields) : self
Parameters
- $action : string
- $fields : array<string, mixed>
Return values
selfsnapshot()
private
snapshot() : Snapshot
Return values
Snapshotwire()
private
wire() : string