You are here

public function WidgetIntegrationTest::testLinksShowHideCount in Facets 8

Tests the functionality of a widget to hide/show the item-count.

File

tests/src/Functional/WidgetIntegrationTest.php, line 89

Class

WidgetIntegrationTest
Tests the overall functionality of the Facets admin UI.

Namespace

Drupal\Tests\facets\Functional

Code

public function testLinksShowHideCount() {
  $id = 'links_widget';
  $facet_edit_page = 'admin/config/search/facets/' . $id . '/edit';
  $this
    ->createFacet('>.Facet &* Links', $id);

  // Go to the view and check that the facet links are shown with their
  // default settings.
  $this
    ->drupalGet('search-api-test-fulltext');
  $this
    ->assertFacetLabel('item');
  $this
    ->assertFacetLabel('article');
  $this
    ->drupalGet($facet_edit_page);
  $this
    ->drupalPostForm(NULL, [
    'widget' => 'links',
    'widget_config[show_numbers]' => TRUE,
  ], 'Save');

  // Go back to the same view and check that links now display the count.
  $this
    ->drupalGet('search-api-test-fulltext');
  $this
    ->assertFacetLabel('item (3)');
  $this
    ->assertFacetLabel('article (2)');
  $edit = [
    'widget' => 'links',
    'widget_config[show_numbers]' => TRUE,
    'facet_settings[query_operator]' => 'or',
  ];
  $this
    ->drupalPostForm($facet_edit_page, $edit, 'Save');
  $this
    ->drupalGet('search-api-test-fulltext');
  $this
    ->assertFacetLabel('item (3)');
  $this
    ->assertFacetLabel('article (2)');
  $this
    ->clickPartialLink('item');
  $this
    ->assertFacetLabel('item (3)');
  $this
    ->assertFacetLabel('article (2)');
  $this
    ->drupalGet($facet_edit_page);
  $this
    ->drupalPostForm(NULL, [
    'widget' => 'links',
    'widget_config[show_numbers]' => FALSE,
  ], 'Save');

  // The count should be hidden again.
  $this
    ->drupalGet('search-api-test-fulltext');
  $this
    ->assertFacetLabel('item');
  $this
    ->assertFacetLabel('article');
}