Add tests for the Connectors

Created on 25 June 2025, about 1 month ago

Problem/Motivation

At time-of-writing, we have two Elasticsearch connectors (\Drupal\elasticsearch_connector\Plugin\ElasticSearch\Connector\StandardConnector and \Drupal\elasticsearch_connector\Plugin\ElasticSearch\Connector\BasicAuthConnector), but neither have tests. Connect to an Elastic Cloud Hosted Deployment acting as a Search API Server by entering a Cloud ID and API key Active adds two more connectors.

Currently, the connectors don't have tests. Have ElasticSearchConnectorInterface::getClient() return an Elasticsearch ClientInterface instead of a Client Active might make it slightly easier to substitute a test double for the Elasticsearch Client, but it's unclear if that issue blocks this one or not.

Proposed resolution

Ensure that the Connectors are tested, i.e.: they should have:

  1. Tests that the client uses the connection options specified (e.g.: no authentication, HTTP Basic Auth, API key, etc.).
  2. Functional tests for the UI, ensuring the config forms save the values entered into them

Adding tests for the connection options might look like:

  1. Specify a test-double PSR-7 HttpClient when building the client (i.e.: with \Elastic\Elasticsearch\ClientBuilder::setHttpClient()) that logs messages sent.
  2. In a test, try connecting, and check if the messages contain the connection options specified.

Adding tests for the UI might look like:

  1. Add a Search API server using the config form and ensure the values are saved.
  2. Edit a Search API server using the config form and ensure the new values are saved.

Remaining tasks

  1. Write a patch
  2. Review and feedback
  3. RTBC and feedback
  4. Commit
  5. Release

User interface changes

None anticipated.

API changes

Unknown, hopefully none.

Data model changes

None anticipated.

Feature request
Status

Postponed

Version

8.0

Component

Code

Created by

🇨🇦Canada mparker17 UTC-4

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024