trait InteractsWithAlgolia

Add Algolia support to an integration test.

Use this trait on a test case and set ALGOLIA_APP_ID and ALGOLIA_SECRET. Test indexes are isolated and cleaned up using a TEST_TOKEN-based prefix.

Properties

protected string $algoliaTestPrefix

The test prefix for index isolation.

protected SearchClient|null $algolia

The Algolia client instance.

protected HttpClientInterface|null $previousAlgoliaHttpClient

The HTTP client installed before this test.

Methods

void
setUpInteractsWithAlgolia()

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

void
tearDownInteractsWithAlgolia()

Tear down Algolia (auto-called via beforeApplicationDestroyed).

HttpClientInterface
createAlgoliaHttpClient()

Create the Algolia HTTP client.

void
computeAlgoliaTestPrefix()

Compute the test prefix for parallel-safe index names.

void
cleanupAlgoliaIndices()

Clean up all test indexes matching the test prefix.

Details

at line 44
protected void setUpInteractsWithAlgolia()

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

Algolia integration tests are opt-in via ALGOLIA_APP_ID and ALGOLIA_SECRET. If credentials are set but the probe fails, the exception propagates so the test fails loudly.

Return Value

void

at line 80
protected void tearDownInteractsWithAlgolia()

Tear down Algolia (auto-called via beforeApplicationDestroyed).

Return Value

void

at line 99
protected HttpClientInterface createAlgoliaHttpClient()

Create the Algolia HTTP client.

Return Value

HttpClientInterface

at line 107
protected void computeAlgoliaTestPrefix()

Compute the test prefix for parallel-safe index names.

Return Value

void

at line 118
protected void cleanupAlgoliaIndices()

Clean up all test indexes matching the test prefix.

Return Value

void