You are here

public function IntegrationTest::testAndOrFacet in Facets 8

Tests the facet's and/or functionality.

File

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

Class

IntegrationTest
Tests the overall functionality of the Facets admin UI.

Namespace

Drupal\Tests\facets\Functional

Code

public function testAndOrFacet() {
  $facet_name = 'test & facet';
  $facet_id = 'test_facet';
  $facet_edit_page = 'admin/config/search/facets/' . $facet_id . '/edit';
  $this
    ->createFacet($facet_name, $facet_id);
  $this
    ->drupalGet($facet_edit_page);
  $this
    ->drupalPostForm(NULL, [
    'facet_settings[query_operator]' => 'and',
  ], 'Save');
  $this
    ->drupalGet('search-api-test-fulltext');
  $this
    ->assertFacetLabel('item');
  $this
    ->assertFacetLabel('article');
  $this
    ->clickLink('item');
  $this
    ->checkFacetIsActive('item');
  $this
    ->assertSession()
    ->linkNotExists('article');
  $this
    ->drupalGet($facet_edit_page);
  $this
    ->drupalPostForm(NULL, [
    'facet_settings[query_operator]' => 'or',
  ], 'Save');
  $this
    ->drupalGet('search-api-test-fulltext');
  $this
    ->assertFacetLabel('item');
  $this
    ->assertFacetLabel('article');
  $this
    ->clickLink('item');
  $this
    ->checkFacetIsActive('item');
  $this
    ->assertFacetLabel('article');

  // Verify the number of results for OR functionality.
  $this
    ->drupalGet($facet_edit_page);
  $this
    ->drupalPostForm(NULL, [
    'widget' => 'links',
    'widget_config[show_numbers]' => TRUE,
  ], 'Save');
  $this
    ->drupalGet('search-api-test-fulltext');
  $this
    ->clickLink('item (3)');
  $this
    ->assertFacetLabel('article (2)');
}