function MenuTreeStorageTest::testSubtreeHeight

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php \Drupal\KernelTests\Core\Menu\MenuTreeStorageTest::testSubtreeHeight()
  2. 10 core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php \Drupal\KernelTests\Core\Menu\MenuTreeStorageTest::testSubtreeHeight()
  3. 11.x core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php \Drupal\KernelTests\Core\Menu\MenuTreeStorageTest::testSubtreeHeight()

Tests finding the subtree height with content menu links.

File

core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php, line 291

Class

MenuTreeStorageTest
Tests the menu tree storage.

Namespace

Drupal\KernelTests\Core\Menu

Code

public function testSubtreeHeight() {
    // root
    // - child1
    // -- child2
    // --- child3
    // ---- child4
    $this->addMenuLink('root');
    $this->addMenuLink('child1', 'root');
    $this->addMenuLink('child2', 'child1');
    $this->addMenuLink('child3', 'child2');
    $this->addMenuLink('child4', 'child3');
    $this->assertEqual($this->treeStorage
        ->getSubtreeHeight('root'), 5);
    $this->assertEqual($this->treeStorage
        ->getSubtreeHeight('child1'), 4);
    $this->assertEqual($this->treeStorage
        ->getSubtreeHeight('child2'), 3);
    $this->assertEqual($this->treeStorage
        ->getSubtreeHeight('child3'), 2);
    $this->assertEqual($this->treeStorage
        ->getSubtreeHeight('child4'), 1);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.