You are here

public function AggregatedFieldTest::testAggregatedField in Facets 8

Tests aggregated fields.

See also

https://www.drupal.org/node/2917323

File

tests/src/Functional/AggregatedFieldTest.php, line 86

Class

AggregatedFieldTest
Class AggregatedFieldTest.

Namespace

Drupal\Tests\facets\Functional

Code

public function testAggregatedField() {
  $facet_id = 'test_agg';

  // Go to the Add facet page and make sure that returns a 200.
  $facet_add_page = '/admin/config/search/facets/add-facet';
  $this
    ->drupalGet($facet_add_page);
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $form_values = [
    'name' => 'Test agg',
    'id' => $facet_id,
    'facet_source_id' => 'search_api:views_page__search_api_test_view__page_1',
    'facet_source_configs[search_api:views_page__search_api_test_view__page_1][field_identifier]' => 'aggregated_field',
  ];

  // Try filling out the form, and configure it to use the aggregated field.
  $this
    ->drupalPostForm(NULL, [
    'facet_source_id' => 'search_api:views_page__search_api_test_view__page_1',
  ], 'Configure facet source');
  $this
    ->drupalPostForm(NULL, $form_values, 'Save');

  // Check that nothing breaks.
  $this
    ->assertSession()
    ->statusCodeEquals(200);
}