You are here

protected function HierarchicalFacetIntegrationTest::verifyUseHierarchyOption in Facets 8

Verify the backend option "Use hierarchy" is working.

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

File

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

Class

HierarchicalFacetIntegrationTest
Tests the hierarchical facets implementation.

Namespace

Drupal\Tests\facets\Functional

Code

protected function verifyUseHierarchyOption() {

  // Verify that the link to the index processors settings page is available.
  $this
    ->drupalGet($this->facetEditPage);
  $this
    ->clickLink('Search api index processor configuration');
  $this
    ->assertSession()
    ->statusCodeEquals(200);

  // Enable hierarchical facets and translation of entity ids to its names for
  // a better readability.
  $this
    ->drupalGet($this->facetEditPage);
  $edit = [
    'facet_settings[use_hierarchy]' => '1',
    'facet_settings[translate_entity][status]' => TRUE,
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save');

  // Child elements should be collapsed and invisible.
  $this
    ->drupalGet('search-api-test-fulltext');
  $this
    ->assertFacetLabel('Parent 1');
  $this
    ->assertFacetLabel('Parent 2');
  $this
    ->assertSession()
    ->linkNotExists('Child 1');
  $this
    ->assertSession()
    ->linkNotExists('Child 2');
  $this
    ->assertSession()
    ->linkNotExists('Child 3');
  $this
    ->assertSession()
    ->linkNotExists('Child 4');

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