trait InteractsWithMeilisearch

Add Meilisearch support to an integration test.

Use this trait on a test case and set MEILISEARCH_HOST. MEILISEARCH_PORT and MEILISEARCH_KEY may also be configured. Test indexes are isolated and cleaned up using a TEST_TOKEN-based prefix.

Properties

protected string $meilisearchTestPrefix

The test prefix for index isolation.

protected Client|null $meilisearch

The Meilisearch client instance.

Methods

void
setUpInteractsWithMeilisearch()

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

void
tearDownInteractsWithMeilisearch()

Tear down Meilisearch (auto-called via beforeApplicationDestroyed).

void
initializeMeilisearchClient()

Initialize the Meilisearch client.

void
computeMeilisearchTestPrefix()

Compute the test prefix for parallel-safe index names.

string
getMeilisearchHost()

Get the Meilisearch host URL.

void
cleanupMeilisearchIndexes()

Clean up all test indexes matching the test prefix.

void
waitForMeilisearchTasks(int $timeoutMs = 5000)

Wait for all pending Meilisearch tasks to complete.

Details

at line 35
protected void setUpInteractsWithMeilisearch()

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

Meilisearch integration tests are opt-in via MEILISEARCH_HOST. Port and key settings are only read after MEILISEARCH_HOST is present.

Return Value

void

at line 57
protected void tearDownInteractsWithMeilisearch()

Tear down Meilisearch (auto-called via beforeApplicationDestroyed).

Return Value

void

at line 75
protected void initializeMeilisearchClient()

Initialize the Meilisearch client.

Return Value

void

at line 86
protected void computeMeilisearchTestPrefix()

Compute the test prefix for parallel-safe index names.

Return Value

void

at line 99
protected string getMeilisearchHost()

Get the Meilisearch host URL.

Builds URL from MEILISEARCH_HOST and MEILISEARCH_PORT env vars.

Return Value

string

at line 110
protected void cleanupMeilisearchIndexes()

Clean up all test indexes matching the test prefix.

Return Value

void

at line 132
protected void waitForMeilisearchTasks(int $timeoutMs = 5000)

Wait for all pending Meilisearch tasks to complete.

Parameters

int $timeoutMs

Return Value

void