Testing
Anvil\Test\InteractsWithAnvil sends actions through the real dispatcher,
as the browser would:
| Method | Purpose |
|---|---|
grantPermissions(array $permissions) |
the current user has exactly these permissions |
dispatchComponent($panel, $component, $action, $input = [], $record = null, $context = []) |
issues a token for <panel>:<component> (current tenant, optional record UUID and context) and dispatches the action; returns the ComponentResponse |
assertRejected(int $status, callable $callback) |
asserts an EndpointException with this status and returns it (errors, reason) |
$componentis given without the panel:triage:ticketsfor a page component,projects:checklistfor a detail component. For components registered withregister(), the id must start with<panel>:to be reachable this way.- The response exposes
html,status,events,redirectanddownload. - Token check, permissions, validation, transaction and audit run as in
production. Actions with
Gate::AUTHENTICATEDalso need a logged in user (actingAs($user)).
Set-up of the test database, tenants and users: Testing.