You are here

protected function DefaultMenuLinkTreeManipulatorsTest::mockTree in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php \Drupal\Tests\Core\Menu\DefaultMenuLinkTreeManipulatorsTest::mockTree()

Creates a mock tree.

This mocks a tree with the following structure:

  • 1
  • 2
    • 3

      • 4
  • 5
    • 7
  • 6
  • 8
  • 9

With link 6 being the only external link.

4 calls to DefaultMenuLinkTreeManipulatorsTest::mockTree()
DefaultMenuLinkTreeManipulatorsTest::testCheckAccess in core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php
Tests the checkAccess() tree manipulator.
DefaultMenuLinkTreeManipulatorsTest::testCheckAccessWithLinkToAnyPagePermission in core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php
Tests checkAccess() tree manipulator with 'link to any page' permission.
DefaultMenuLinkTreeManipulatorsTest::testFlatten in core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php
Tests the flatten() tree manipulator.
DefaultMenuLinkTreeManipulatorsTest::testGenerateIndexAndSort in core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php
Tests the generateIndexAndSort() tree manipulator.

File

core/tests/Drupal/Tests/Core/Menu/DefaultMenuLinkTreeManipulatorsTest.php, line 109
Contains \Drupal\Tests\Core\Menu\DefaultMenuLinkTreeManipulatorsTest.

Class

DefaultMenuLinkTreeManipulatorsTest
Tests the default menu link tree manipulators.

Namespace

Drupal\Tests\Core\Menu

Code

protected function mockTree() {
  $this->links = array(
    1 => MenuLinkMock::create(array(
      'id' => 'test.example1',
      'route_name' => 'example1',
      'title' => 'foo',
      'parent' => '',
    )),
    2 => MenuLinkMock::create(array(
      'id' => 'test.example2',
      'route_name' => 'example2',
      'title' => 'bar',
      'parent' => 'test.example1',
      'route_parameters' => array(
        'foo' => 'bar',
      ),
    )),
    3 => MenuLinkMock::create(array(
      'id' => 'test.example3',
      'route_name' => 'example3',
      'title' => 'baz',
      'parent' => 'test.example2',
      'route_parameters' => array(
        'baz' => 'qux',
      ),
    )),
    4 => MenuLinkMock::create(array(
      'id' => 'test.example4',
      'route_name' => 'example4',
      'title' => 'qux',
      'parent' => 'test.example3',
    )),
    5 => MenuLinkMock::create(array(
      'id' => 'test.example5',
      'route_name' => 'example5',
      'title' => 'foofoo',
      'parent' => '',
    )),
    6 => MenuLinkMock::create(array(
      'id' => 'test.example6',
      'route_name' => '',
      'url' => 'https://www.drupal.org/',
      'title' => 'barbar',
      'parent' => '',
    )),
    7 => MenuLinkMock::create(array(
      'id' => 'test.example7',
      'route_name' => 'example7',
      'title' => 'bazbaz',
      'parent' => '',
    )),
    8 => MenuLinkMock::create(array(
      'id' => 'test.example8',
      'route_name' => 'example8',
      'title' => 'quxqux',
      'parent' => '',
    )),
    9 => DynamicMenuLinkMock::create(array(
      'id' => 'test.example9',
      'parent' => '',
    ))
      ->setCurrentUser($this->currentUser),
  );
  $this->originalTree = array();
  $this->originalTree[1] = new MenuLinkTreeElement($this->links[1], FALSE, 1, FALSE, array());
  $this->originalTree[2] = new MenuLinkTreeElement($this->links[2], TRUE, 1, FALSE, array(
    3 => new MenuLinkTreeElement($this->links[3], TRUE, 2, FALSE, array(
      4 => new MenuLinkTreeElement($this->links[4], FALSE, 3, FALSE, array()),
    )),
  ));
  $this->originalTree[5] = new MenuLinkTreeElement($this->links[5], TRUE, 1, FALSE, array(
    7 => new MenuLinkTreeElement($this->links[7], FALSE, 2, FALSE, array()),
  ));
  $this->originalTree[6] = new MenuLinkTreeElement($this->links[6], FALSE, 1, FALSE, array());
  $this->originalTree[8] = new MenuLinkTreeElement($this->links[8], FALSE, 1, FALSE, array());
  $this->originalTree[9] = new MenuLinkTreeElement($this->links[9], FALSE, 1, FALSE, array());
}