You are here

public function IntegrationTest::testHardLimit in Facets 8

Tests the hard limit setting.

File

tests/src/Functional/IntegrationTest.php, line 662

Class

IntegrationTest
Tests the overall functionality of the Facets admin UI.

Namespace

Drupal\Tests\facets\Functional

Code

public function testHardLimit() {
  $this
    ->createFacet('Owl', 'owl', 'keywords');
  $edit = [
    'widget' => 'links',
    'widget_config[show_numbers]' => '1',
    'facet_sorting[display_value_widget_order][status]' => TRUE,
    'facet_sorting[active_widget_order][status]' => FALSE,
  ];
  $this
    ->drupalPostForm('admin/config/search/facets/owl/edit', $edit, 'Save');
  $this
    ->drupalGet('search-api-test-fulltext');
  $this
    ->assertSession()
    ->pageTextContains('Displaying 5 search results');
  $this
    ->assertFacetLabel('grape (3)');
  $this
    ->assertFacetLabel('orange (3)');
  $this
    ->assertFacetLabel('apple (2)');
  $this
    ->assertFacetLabel('banana (1)');
  $this
    ->assertFacetLabel('strawberry (2)');
  $edit['facet_settings[hard_limit]'] = 3;
  $this
    ->drupalPostForm('admin/config/search/facets/owl/edit', $edit, 'Save');
  $this
    ->drupalGet('search-api-test-fulltext');

  // We're still testing for 5 search results here, the hard limit only limits
  // the facets, not the search results.
  $this
    ->assertSession()
    ->pageTextContains('Displaying 5 search results');
  $this
    ->assertFacetLabel('grape (3)');
  $this
    ->assertFacetLabel('orange (3)');
  $this
    ->assertFacetLabel('apple (2)');
  $this
    ->assertSession()
    ->pageTextNotContains('banana (0)');
  $this
    ->assertSession()
    ->pageTextNotContains('strawberry (0)');
}