You are here

public function ProcessorIntegrationTest::checkAggregatedFieldsIntegration in Search API 8

Tests the integration of the "Aggregated fields" processor.

1 call to ProcessorIntegrationTest::checkAggregatedFieldsIntegration()
ProcessorIntegrationTest::testProcessorIntegration in tests/src/Functional/ProcessorIntegrationTest.php
Tests the admin UI for processors.

File

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

Class

ProcessorIntegrationTest
Tests the admin UI for processors.

Namespace

Drupal\Tests\search_api\Functional

Code

public function checkAggregatedFieldsIntegration() {
  $index = $this
    ->loadIndex();
  $index
    ->removeProcessor('aggregated_field');
  $index
    ->save();
  $this
    ->assertTrue($this
    ->loadIndex()
    ->isValidProcessor('aggregated_field'), 'The "Aggregated fields" processor cannot be disabled.');
  $options['query']['datasource'] = '';
  $this
    ->drupalGet($this
    ->getIndexPath('fields/add/nojs'), $options);

  // See \Drupal\search_api\Tests\IntegrationTest::addField().
  $this
    ->assertSession()
    ->responseContains('name="aggregated_field"');
  $this
    ->submitForm([], 'aggregated_field');
  $args['%label'] = 'Aggregated field';
  $this
    ->assertSession()
    ->responseContains(new FormattableMarkup('Field %label was added to the index.', $args));
  $this
    ->assertSession()
    ->addressEquals($this
    ->getIndexPath('fields/edit/aggregated_field'));
  $edit = [
    'type' => 'first',
    'fields[entity:node/title]' => 'title',
    'fields[entity:node/type]' => 'type',
    'fields[entity:node/uid]' => 'uid',
  ];
  $this
    ->submitForm($edit, 'Save');
  $this
    ->assertSession()
    ->addressEquals($this
    ->getIndexPath('fields'));
  $this
    ->assertSession()
    ->responseContains('The field configuration was successfully saved.');
}