public function HierarchicalTaxonomyMenuDynamicTest::testDynamicBehaviourWhenNotCollapsed in Hierarchical Taxonomy Menu 8
Tests dynamic behaviour when menu items are not collapsed.
File
- tests/
src/ FunctionalJavascript/ HierarchicalTaxonomyMenuDynamicTest.php, line 200
Class
- HierarchicalTaxonomyMenuDynamicTest
- Tests the Hierarchical Taxonomy Menu dynamic behaviour.
Namespace
Drupal\Tests\hierarchical_taxonomy_menu\FunctionalJavascriptCode
public function testDynamicBehaviourWhenNotCollapsed() {
$this->block
->set('settings', [
'label' => 'Hierarchical Taxonomy Menu',
'label_display' => 'visible',
'vocabulary' => $this->vocabulary
->id() . '|',
'collapsible' => FALSE,
]);
$this->block
->save();
$this
->drupalGet('<front>');
// We should see all items.
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
->clickLink('Parent term 1');
// We should see parents and Parent term 2 and 3 descendants.
for ($i = 1; $i < 4; $i++) {
$this
->assertSession()
->pageTextContains('Parent term ' . $i);
if ($i == 1) {
for ($n = 1; $n < 12; $n++) {
$this
->assertSession()
->pageTextNotContains('Child term ' . $i . '-' . $n);
}
}
else {
for ($n = 1; $n < 12; $n++) {
$this
->assertSession()
->pageTextContains('Child term ' . $i . '-' . $n);
}
}
}
$this
->clickLink('Parent term 2');
// We should see parents and Parent term 3 descendants.
for ($i = 1; $i < 4; $i++) {
$this
->assertSession()
->pageTextContains('Parent term ' . $i);
if ($i == 1 || $i == 2) {
for ($n = 1; $n < 12; $n++) {
$this
->assertSession()
->pageTextNotContains('Child term ' . $i . '-' . $n);
}
}
else {
for ($n = 1; $n < 12; $n++) {
$this
->assertSession()
->pageTextContains('Child term ' . $i . '-' . $n);
}
}
}
$this
->clickLink('Parent term 3');
// We should see just parents. All descendants must be hidden.
for ($i = 1; $i < 4; $i++) {
$this
->assertSession()
->pageTextContains('Parent term ' . $i);
for ($n = 1; $n < 12; $n++) {
$this
->assertSession()
->pageTextNotContains('Child term ' . $i . '-' . $n);
}
}
}