You are here

public function HierarchicalTaxonomyMenuAdvancedTest::testBaseTerm in Hierarchical Taxonomy Menu 8

Test base term.

File

tests/src/FunctionalJavascript/HierarchicalTaxonomyMenuAdvancedTest.php, line 168

Class

HierarchicalTaxonomyMenuAdvancedTest
Tests the Hierarchical Taxonomy Menu advanced config options.

Namespace

Drupal\Tests\hierarchical_taxonomy_menu\FunctionalJavascript

Code

public function testBaseTerm() {
  $this->block
    ->set('settings', [
    'label' => 'Hierarchical Taxonomy Menu',
    'label_display' => 'visible',
    'vocabulary' => $this->vocabulary
      ->id() . '|',
    'base_term' => 3,
  ]);
  $this->block
    ->save();
  $this
    ->drupalGet('<front>');
  for ($i = 1; $i < 4; $i++) {
    $this
      ->assertSession()
      ->pageTextNotContains('Parent term ' . $i);
    for ($n = 1; $n < 12; $n++) {
      if ($i == 1 && $n > 2) {
        $this
          ->assertSession()
          ->pageTextContains('Child term ' . $i . '-' . $n);
      }
      else {

        // We need that empty space at the end because Child term 1-10 and
        // Child term 1-11 contain substring Child term 1-1.
        $this
          ->assertSession()
          ->pageTextNotContains('Child term ' . $i . '-' . $n . ' ');
      }
    }
  }
}