You are here

public function ProcessorIntegrationTest::testProcessorConfig in Facets 8

Tests the configuration of the processors.

File

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

Class

ProcessorIntegrationTest
Tests the processor functionality.

Namespace

Drupal\Tests\facets\Functional

Code

public function testProcessorConfig() {
  $this
    ->createFacet('Llama', 'llama');
  $facet_id = 'alpaca';
  $this->editForm = 'admin/config/search/facets/' . $facet_id . '/edit';
  $this
    ->createFacet('Alpaca', $facet_id);
  $this
    ->drupalGet($this->editForm);
  $facet = Facet::load($facet_id);

  /** @var \Drupal\facets\Processor\ProcessorInterface $processor */
  foreach ($facet
    ->getProcessors(FALSE) as $processor) {

    // Sort processors have a different form key, so don't bother for now.
    if ($processor instanceof SortProcessorInterface) {
      continue;
    }

    // These processors are hidden by default, see also
    // ::testHiddenProcessors.
    $hiddenProcessors = [
      'boolean_item',
      'translate_entity',
      'translate_entity_aggregated_fields',
      'uid_to_username_callback',
    ];
    if (in_array($processor
      ->getPluginId(), $hiddenProcessors)) {
      continue;
    }
    $this
      ->drupalPostForm(NULL, [
      "facet_settings[{$processor->getPluginId()}][status]" => '1',
    ], 'Save');
    $this
      ->assertSession()
      ->statusCodeEquals(200);
  }
}