public function HierarchicalTaxonomyMenuAdvancedTest::testDynamicBaseTerm in Hierarchical Taxonomy Menu 8
Test dynamic base term.
File
- tests/
src/ FunctionalJavascript/ HierarchicalTaxonomyMenuAdvancedTest.php, line 198
Class
- HierarchicalTaxonomyMenuAdvancedTest
- Tests the Hierarchical Taxonomy Menu advanced config options.
Namespace
Drupal\Tests\hierarchical_taxonomy_menu\FunctionalJavascriptCode
public function testDynamicBaseTerm() {
$this->block
->set('settings', [
'label' => 'Hierarchical Taxonomy Menu',
'label_display' => 'visible',
'vocabulary' => $this->vocabulary
->id() . '|',
'dynamic_base_term' => TRUE,
]);
$this->block
->save();
$this
->drupalGet('<front>');
// In this case we should see all terms.
for ($i = 1; $i < 4; $i++) {
$this
->assertSession()
->pageTextContains('Parent term ' . $i);
for ($n = 1; $n < 12; $n++) {
$this
->assertSession()
->pageTextContains('Child term ' . $i . '-' . $n);
}
}
$this
->drupalGet('taxonomy/term/1');
// In this case we should see just Term #1 children.
for ($i = 1; $i < 4; $i++) {
$this
->assertSession()
->pageTextNotContains('Parent term ' . $i);
for ($n = 1; $n < 12; $n++) {
if ($i == 1) {
$this
->assertSession()
->pageTextContains('Child term ' . $i . '-' . $n);
}
else {
$this
->assertSession()
->pageTextNotContains('Child term ' . $i . '-' . $n);
}
}
}
$this
->drupalGet('taxonomy/term/13');
// In this case we should see just Term #13 children.
for ($i = 1; $i < 4; $i++) {
$this
->assertSession()
->pageTextNotContains('Parent term ' . $i);
for ($n = 1; $n < 12; $n++) {
if ($i == 2) {
$this
->assertSession()
->pageTextContains('Child term ' . $i . '-' . $n);
}
else {
$this
->assertSession()
->pageTextNotContains('Child term ' . $i . '-' . $n);
}
}
}
$this
->drupalGet('taxonomy/term/25');
// In this case we should see just Term #25 children.
for ($i = 1; $i < 4; $i++) {
$this
->assertSession()
->pageTextNotContains('Parent term ' . $i);
for ($n = 1; $n < 12; $n++) {
if ($i == 3) {
$this
->assertSession()
->pageTextContains('Child term ' . $i . '-' . $n);
}
else {
$this
->assertSession()
->pageTextNotContains('Child term ' . $i . '-' . $n);
}
}
}
$this
->drupalGet('taxonomy/term/33');
// In this case we should see just Term #33 children.
for ($i = 1; $i < 4; $i++) {
$this
->assertSession()
->pageTextNotContains('Parent term ' . $i);
for ($n = 1; $n < 12; $n++) {
if ($i == 3 && $n > 8) {
$this
->assertSession()
->pageTextContains('Child term ' . $i . '-' . $n);
}
else {
// We need that empty space at the end because Child term 3-10 and
// Child term 3-11 contain substring Child term 3-1.
$this
->assertSession()
->pageTextNotContains('Child term ' . $i . '-' . $n . ' ');
}
}
}
}