You are here

protected function HierarchicalFacetIntegrationTest::verifyKeepHierarchyParentsActiveOption in Facets 8

Verify the "Keep parents active" option is working.

1 call to HierarchicalFacetIntegrationTest::verifyKeepHierarchyParentsActiveOption()
HierarchicalFacetIntegrationTest::testHierarchicalFacet in tests/src/Functional/HierarchicalFacetIntegrationTest.php
Test the hierarchical facets functionality.

File

tests/src/Functional/HierarchicalFacetIntegrationTest.php, line 154

Class

HierarchicalFacetIntegrationTest
Tests the hierarchical facets implementation.

Namespace

Drupal\Tests\facets\Functional

Code

protected function verifyKeepHierarchyParentsActiveOption() {

  // Expand the hierarchy and verify that all items are visible initially.
  $this
    ->drupalGet($this->facetEditPage);
  $edit = [
    'facet_settings[expand_hierarchy]' => FALSE,
    'facet_settings[keep_hierarchy_parents_active]' => '1',
    'facet_settings[use_hierarchy]' => '1',
    'facet_settings[translate_entity][status]' => '1',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save');
  $this
    ->drupalGet('search-api-test-fulltext');

  // Click the first parent and make sure its children are visible.
  $this
    ->clickLink('Parent 1');
  $this
    ->checkFacetIsActive('Parent 1');
  $this
    ->checkFacetIsNotActive('Child 1');
  $this
    ->checkFacetIsNotActive('Child 2');
  $this
    ->assertFacetLabel('Child 1');
  $this
    ->assertFacetLabel('Child 2');
  $this
    ->assertSession()
    ->linkNotExists('Child 3');
  $this
    ->assertSession()
    ->linkNotExists('Child 4');

  // Click the first child and make sure its parent is still active.
  $this
    ->clickLink('Child 1');
  $this
    ->checkFacetIsActive('Parent 1');
  $this
    ->checkFacetIsActive('Child 1');
  $this
    ->checkFacetIsNotActive('Child 2');
  $this
    ->assertFacetLabel('Child 1');
  $this
    ->assertFacetLabel('Child 2');
  $this
    ->assertSession()
    ->linkNotExists('Child 3');
  $this
    ->assertSession()
    ->linkNotExists('Child 4');

  // Click the the parent and make sure its children are not active, too.
  $this
    ->clickLink('Parent 1');
  $this
    ->checkFacetIsNotActive('Parent 1');
  $this
    ->assertSession()
    ->linkNotExists('Child 1');
  $this
    ->assertSession()
    ->linkNotExists('Child 2');
  $this
    ->assertSession()
    ->linkNotExists('Child 3');
  $this
    ->assertSession()
    ->linkNotExists('Child 4');
}