You are here

public function DefaultMenuLinkTreeManipulatorsTest::testGenerateIndexAndSort in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 141
Contains \Drupal\Tests\Core\Menu\DefaultMenuLinkTreeManipulatorsTest.

Class

DefaultMenuLinkTreeManipulatorsTest
Tests the default menu link tree manipulators.

Namespace

Drupal\Tests\Core\Menu

Code

public function testGenerateIndexAndSort() {
  $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 foofoo test.example5']->link
    ->getPluginId());
  $this
    ->assertEquals($this->links[6]
    ->getPluginId(), $tree['50000 barbar test.example6']->link
    ->getPluginId());
  $this
    ->assertEquals($this->links[8]
    ->getPluginId(), $tree['50000 quxqux 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 foofoo test.example5']->subtree['50000 bazbaz test.example7']->link
    ->getPluginId());
}