trait InteractsWithTypesense

Add Typesense support to an integration test.

Use this trait on a test case and set TYPESENSE_HOST and TYPESENSE_API_KEY. TYPESENSE_PORT and TYPESENSE_PROTOCOL may also be configured. Test collections are isolated and cleaned up using a TEST_TOKEN-based prefix.

Properties

protected string $typesenseTestPrefix

The test prefix for collection isolation.

protected Client|null $typesense

The Typesense client instance.

Methods

void
setUpInteractsWithTypesense()

Set up Typesense for testing (auto-called by setUpTraits).

void
tearDownInteractsWithTypesense()

Tear down Typesense (auto-called via beforeApplicationDestroyed).

void
initializeTypesenseClient()

Initialize the Typesense client.

array
getTypesenseClientSettings()

Get Typesense client settings.

void
computeTypesenseTestPrefix()

Compute the test prefix for parallel-safe collection names.

void
cleanupTypesenseCollections()

Clean up all test collections matching the test prefix.

Details

at line 35
protected void setUpInteractsWithTypesense()

Set up Typesense for testing (auto-called by setUpTraits).

Typesense integration tests are opt-in via TYPESENSE_HOST. Port, protocol, and API key settings are only read after TYPESENSE_HOST is present.

Return Value

void

at line 55
protected void tearDownInteractsWithTypesense()

Tear down Typesense (auto-called via beforeApplicationDestroyed).

Return Value

void

at line 73
protected void initializeTypesenseClient()

Initialize the Typesense client.

Return Value

void

at line 83
protected array getTypesenseClientSettings()

Get Typesense client settings.

Return Value

array

at line 101
protected void computeTypesenseTestPrefix()

Compute the test prefix for parallel-safe collection names.

Return Value

void

at line 112
protected void cleanupTypesenseCollections()

Clean up all test collections matching the test prefix.

Return Value

void