# Testing API

> AssertableTable entry points, assertions and comparison rules.

Source: https://docs.inertiax.dev/table/reference/testing/

`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.

| Method                                   | Assertion                                   |
| ---------------------------------------- | ------------------------------------------- |
| `isSuccessful()`                         | The table has a successful result           |
| `hasRows(2)`                             | This page contains exactly two rows         |
| `hasRowIds([1, 2])`                      | Exact row identities, in this order         |
| `hasTotal(2)`                            | Matching count before pagination            |
| `hasCellValue(1, 'total_cents', 8419)`   | Raw cell value for the identified row       |
| `hasState('pagination.page', 1)`         | Applied state leaf or complete subtree      |
| `hasProblem('filters')`                  | An `invalid-url-state` issue for that field |
| `hasProblem('page', 'page-unavailable')` | The requested page is unavailable           |
| `allowsReset(false)`                     | 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.

## Envelope and component inputs

`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](https://docs.inertiax.dev/table/guide/testing/) for a complete feature-test example.

## Request URLs

`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.
