You are here

protected function ProcessorIntegrationTest::editSettingsForm in Search API 8

Enables a processor with a given configuration.

Parameters

array $configuration: The configuration to set for the processor.

string $processor_id: The ID of the processor to edit.

array|null $form_values: (optional) The processor configuration to set, as it appears in the form. Only relevant if the processor does some processing on the form values before storing them, like parsing YAML or cleaning up checkboxes values. Defaults to using $configuration as-is.

bool $enable: (optional) If TRUE, explicitly enable the processor. If FALSE, it should already be enabled.

bool $unset_fields: (optional) If TRUE, the "fields" property will be removed from the actual configuration prior to comparing with the given configuration.

12 calls to ProcessorIntegrationTest::editSettingsForm()
ProcessorIntegrationTest::checkAddHierarchyIntegration in tests/src/Functional/ProcessorIntegrationTest.php
Tests the hierarchy processor.
ProcessorIntegrationTest::checkEntityBundleBoostIntegration in tests/src/Functional/ProcessorIntegrationTest.php
Tests the UI for the "Type-specific boosting" processor.
ProcessorIntegrationTest::checkHighlightIntegration in tests/src/Functional/ProcessorIntegrationTest.php
Tests the UI for the "Highlight" processor.
ProcessorIntegrationTest::checkHtmlFilterIntegration in tests/src/Functional/ProcessorIntegrationTest.php
Tests the UI for the "HTML filter" processor.
ProcessorIntegrationTest::checkIgnoreCaseIntegration in tests/src/Functional/ProcessorIntegrationTest.php
Tests the UI for the "Ignore case" processor.

... See full list

File

tests/src/Functional/ProcessorIntegrationTest.php, line 781

Class

ProcessorIntegrationTest
Tests the admin UI for processors.

Namespace

Drupal\Tests\search_api\Functional

Code

protected function editSettingsForm(array $configuration, $processor_id, array $form_values = NULL, $enable = TRUE, $unset_fields = TRUE) {
  $this
    ->loadProcessorsTab();
  $edit = $this
    ->getFormValues($form_values ?? $configuration, "processors[{$processor_id}][settings]");
  if ($enable) {
    $edit["status[{$processor_id}]"] = 1;
  }
  $this
    ->submitForm($edit, 'Save');
  $processor = $this
    ->loadIndex()
    ->getProcessor($processor_id);
  $this
    ->assertInstanceOf(ProcessorInterface::class, $processor, "Successfully enabled the '{$processor_id}' processor.'");
  if ($processor) {
    $actual_configuration = $processor
      ->getConfiguration();
    unset($actual_configuration['weights']);
    if ($unset_fields) {
      unset($actual_configuration['fields']);
    }
    $configuration += $processor
      ->defaultConfiguration();
    $this
      ->assertEquals($configuration, $actual_configuration, "Processor configuration for processor '{$processor_id}' was set correctly.");
  }
}