function DefaultMenuLinkTreeManipulatorsTest::testGenerateIndexAndSort
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php \Drupal\Tests\Core\Menu\DefaultMenuLinkTreeManipulatorsTest::testGenerateIndexAndSort()
- 8.9.x core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php \Drupal\Tests\Core\Menu\DefaultMenuLinkTreeManipulatorsTest::testGenerateIndexAndSort()
- 10 core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php \Drupal\Tests\Core\Menu\DefaultMenuLinkTreeManipulatorsTest::testGenerateIndexAndSort()
Tests the generateIndexAndSort() tree manipulator.
@covers ::generateIndexAndSort
File
-
core/
tests/ Drupal/ Tests/ Core/ Menu/ DefaultMenuLinkTreeManipulatorsTest.php, line 153
Class
- DefaultMenuLinkTreeManipulatorsTest
- Tests the default menu link tree manipulators.
Namespace
Drupal\Tests\Core\MenuCode
public function testGenerateIndexAndSort() : void {
$this->mockTree();
$tree = $this->originalTree;
$tree = $this->defaultMenuTreeManipulators
->generateIndexAndSort($tree);
// Validate that parent elements #1, #2, #5 and #6 exist on the root level.
$this->assertEquals($this->links[1]
->getPluginId(), $tree['50000 foo test.example1']->link
->getPluginId());
$this->assertEquals($this->links[2]
->getPluginId(), $tree['50000 bar test.example2']->link
->getPluginId());
$this->assertEquals($this->links[5]
->getPluginId(), $tree['50000 title5 test.example5']->link
->getPluginId());
$this->assertEquals($this->links[6]
->getPluginId(), $tree['50000 bar_bar test.example6']->link
->getPluginId());
$this->assertEquals($this->links[8]
->getPluginId(), $tree['50000 title8 test.example8']->link
->getPluginId());
// Verify that child element #4 is at the correct location in the hierarchy.
$this->assertEquals($this->links[4]
->getPluginId(), $tree['50000 bar test.example2']->subtree['50000 baz test.example3']->subtree['50000 qux test.example4']->link
->getPluginId());
// Verify that child element #7 is at the correct location in the hierarchy.
$this->assertEquals($this->links[7]
->getPluginId(), $tree['50000 title5 test.example5']->subtree['50000 title7 test.example7']->link
->getPluginId());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.