You are here

protected function ProcessorIntegrationTest::checkCountLimitProcessor in Facets 8

Tests the count limit processor.

1 call to ProcessorIntegrationTest::checkCountLimitProcessor()
ProcessorIntegrationTest::testProcessorIntegration in tests/src/Functional/ProcessorIntegrationTest.php
Tests the for processors in the frontend with a 'keywords' facet.

File

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

Class

ProcessorIntegrationTest
Tests the processor functionality.

Namespace

Drupal\Tests\facets\Functional

Code

protected function checkCountLimitProcessor() {
  $this
    ->drupalGet($this->editForm);
  $form = [
    'widget_config[show_numbers]' => TRUE,
    'facet_settings[count_limit][status]' => TRUE,
  ];
  $this
    ->drupalPostForm($this->editForm, $form, 'Save');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->checkboxChecked('edit-facet-settings-count-limit-status');
  $form = [
    'widget_config[show_numbers]' => TRUE,
    'facet_settings[count_limit][status]' => TRUE,
  ];
  $this
    ->drupalPostForm($this->editForm, $form, 'Save');
  $form = [
    'widget_config[show_numbers]' => TRUE,
    'facet_settings[count_limit][status]' => TRUE,
    'facet_settings[count_limit][settings][minimum_items]' => 5,
  ];
  $this
    ->drupalPostForm($this->editForm, $form, 'Save');
  $this
    ->drupalGet('search-api-test-fulltext');
  $this
    ->assertSession()
    ->pageTextContains('Displaying 10 search results');
  $this
    ->assertFacetLabel('grape (6)');
  $this
    ->assertSession()
    ->pageTextNotContains('apple');
  $form = [
    'widget_config[show_numbers]' => TRUE,
    'facet_settings[count_limit][status]' => TRUE,
    'facet_settings[count_limit][settings][minimum_items]' => 1,
    'facet_settings[count_limit][settings][maximum_items]' => 5,
  ];
  $this
    ->drupalPostForm($this->editForm, $form, 'Save');
  $this
    ->drupalGet('search-api-test-fulltext');
  $this
    ->assertSession()
    ->pageTextContains('Displaying 10 search results');
  $this
    ->assertSession()
    ->pageTextNotContains('grape');
  $this
    ->assertFacetLabel('apple (4)');
  $form = [
    'widget_config[show_numbers]' => FALSE,
    'facet_settings[count_limit][status]' => FALSE,
  ];
  $this
    ->drupalPostForm($this->editForm, $form, 'Save');
}