Skip to content

Testing API

InertiaX\Table\Testing\AssertableTable works in PHPUnit and Pest tests. It supports initial HTML, Inertia JSON, and partial responses. The response must be HTTP 200 and contain the named table prop. Use fromEnvelope($envelope) when you already have a complete response envelope.

isSuccessful() Link to isSuccessful
The table has a successful result
hasRows(2) Link to hasRows
This page contains exactly two rows
hasRowIds([1, 2]) Link to hasRowIds
Exact row identities, in this order
hasTotal(2) Link to hasTotal
Matching count before pagination
hasCellValue(1, 'total_cents', 8419) Link to hasCellValue
Raw cell value for the identified row
hasState('pagination.page', 1) Link to hasState
Applied state leaf or complete subtree
hasProblem('filters') Link to hasProblem
An invalid-url-state issue for that field
hasProblem('page', 'page-unavailable') Link to hasProblem
The requested page is unavailable
allowsReset(false) Link to allowsReset
The problem’s server-side reset permission

Missing rows, cells, props, and state paths fail; they never count as null. Numeric identities 1 and 1.0 are equivalent, while the string ID '1' is distinct. Row order and scalar types are preserved in comparisons. Result assertions fail on problem envelopes, even when you expect zero rows.

Table::make('orders')->toArray() returns the component alone. Use ordinary assertions on its data, state and result, or supply the complete response envelope to fromEnvelope(): that entry point expects both protocolVersion and component.

See Testing tables for a complete feature-test example.

InertiaX\Table\Testing\TableRequest::url($path, $table, sort: '-reference', filters: ['status' => 'paid'], search: 'acme') returns a Laravel URL for $this->get(). Sort accepts one key or an ordered list of keys (- means descending); filters are ANDed equals conditions, and a null value in filters asks for is-not-set (the filter must offer it, for example with nullable()). A null argument omits its setting; [] explicitly clears sorting or filters. Existing unrelated query parameters are retained. Use ordinary request URLs for nested filters, other clauses or malformed-input tests.

View Markdown