You are here

protected function HierarchicalFacetIntegrationTest::verifyEnableParentWhenChildGetsDisabledOption in Facets 8

Verify the "Enable parent when child gets disabled" option is working.

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

File

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

Class

HierarchicalFacetIntegrationTest
Tests the hierarchical facets implementation.

Namespace

Drupal\Tests\facets\Functional

Code

protected function verifyEnableParentWhenChildGetsDisabledOption() {

  // Make sure the option is disabled initially.
  $this
    ->drupalGet($this->facetEditPage);
  $edit = [
    'facet_settings[expand_hierarchy]' => '1',
    'facet_settings[keep_hierarchy_parents_active]' => FALSE,
    'facet_settings[enable_parent_when_child_gets_disabled]' => FALSE,
    'facet_settings[use_hierarchy]' => '1',
    'facet_settings[translate_entity][status]' => '1',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save');
  $this
    ->drupalGet('search-api-test-fulltext');

  // Enable a child under Parent 2.
  $this
    ->clickLink('Child 4');
  $this
    ->checkFacetIsActive('Child 4');
  $this
    ->checkFacetIsNotActive('Parent 2');

  // Uncheck the facet again.
  $this
    ->clickLink('(-) Child 4');
  $this
    ->checkFacetIsNotActive('Child 4');
  $this
    ->checkFacetIsNotActive('Parent 2');

  // Enable the option.
  $this
    ->drupalGet($this->facetEditPage);
  $edit = [
    'facet_settings[expand_hierarchy]' => '1',
    'facet_settings[keep_hierarchy_parents_active]' => FALSE,
    'facet_settings[enable_parent_when_child_gets_disabled]' => '1',
    'facet_settings[use_hierarchy]' => '1',
    'facet_settings[translate_entity][status]' => '1',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save');
  $this
    ->drupalGet('search-api-test-fulltext');
  $this
    ->clickLink('Child 4');
  $this
    ->checkFacetIsActive('Child 4');
  $this
    ->clickLink('Child 3');
  $this
    ->checkFacetIsActive('Child 3');
  $this
    ->checkFacetIsActive('Child 4');
  $this
    ->checkFacetIsNotActive('Parent 2');
  $this
    ->clickLink('(-) Child 4');
  $this
    ->checkFacetIsActive('Child 3');
  $this
    ->checkFacetIsNotActive('Child 4');
  $this
    ->checkFacetIsNotActive('Parent 2');
  $this
    ->clickLink('(-) Child 3');
  $this
    ->checkFacetIsNotActive('Child 3');
  $this
    ->checkFacetIsNotActive('Child 4');
  $this
    ->checkFacetIsActive('Parent 2');
}