The integration provides a fake executor so you can assert the queries your code sends without a live database, plus a trait that resets Surqlize's global caches between tests.
Resetting state between tests
Surqlize keeps global state in its ConnectionManager and metadata caches. The RefreshSurqlizeState trait resets it so tests do not leak state into one another.
The trait also offers useSurqlizeExecutor() to set a specific executor, fakeSurrealDB() to fake the managed executor, and resetSurrealDBFakes() to clear fakes.
Faking the executor
SurrealDB::fake() swaps the managed executor for a FakeQueryExecutor that records queries instead of running them. Assert what was sent with assertSurrealQuerySent(), or on the returned fake with assertQuerySent().
The fake also provides assertNothingSent() for asserting that no queries were sent.
Named fakes
Fakes are scoped by connection name, so you can fake one connection and leave the others untouched.
Unit testing without the container
For unit tests that do not boot the application, pass a FakeQueryExecutor directly to a Surqlize query through withExecutor(), or register it globally with useSurqlizeExecutor() from the trait.
Learn more
Container and facades for the facade testing helpers
Queries and transactions for the queries under test
Surqlize connections for executor injection