function DefaultMenuLinkTreeManipulatorsTest::mockTree
Creates a mock tree.
This mocks a tree with the following structure:
- 1
 - 2
- 3
- 4
 
 
 - 3
 - 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::testCheckAccessTreeManipulator in core/
tests/ Drupal/ Tests/ Core/ Menu/ DefaultMenuLinkTreeManipulatorsTest.php  - Tests checkAccess() tree manipulator.
 - 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 121  
Class
- DefaultMenuLinkTreeManipulatorsTest
 - Tests the default menu link tree manipulators.
 
Namespace
Drupal\Tests\Core\MenuCode
protected function mockTree() {
  $this->links = [
    1 => MenuLinkMock::create([
      'id' => 'test.example1',
      'route_name' => 'example1',
      'title' => 'foo',
      'parent' => '',
    ]),
    2 => MenuLinkMock::create([
      'id' => 'test.example2',
      'route_name' => 'example2',
      'title' => 'bar',
      'parent' => 'test.example1',
      'route_parameters' => [
        'foo' => 'bar',
      ],
    ]),
    3 => MenuLinkMock::create([
      'id' => 'test.example3',
      'route_name' => 'example3',
      'title' => 'baz',
      'parent' => 'test.example2',
      'route_parameters' => [
        'baz' => 'qux',
      ],
    ]),
    4 => MenuLinkMock::create([
      'id' => 'test.example4',
      'route_name' => 'example4',
      'title' => 'qux',
      'parent' => 'test.example3',
    ]),
    5 => MenuLinkMock::create([
      'id' => 'test.example5',
      'route_name' => 'example5',
      'title' => 'title5',
      'parent' => '',
    ]),
    6 => MenuLinkMock::create([
      'id' => 'test.example6',
      'route_name' => '',
      'url' => 'https://www.drupal.org/',
      'title' => 'barbar',
      'parent' => '',
    ]),
    7 => MenuLinkMock::create([
      'id' => 'test.example7',
      'route_name' => 'example7',
      'title' => 'title7',
      'parent' => '',
    ]),
    8 => MenuLinkMock::create([
      'id' => 'test.example8',
      'route_name' => 'example8',
      'title' => 'title8',
      'parent' => '',
    ]),
    9 => DynamicMenuLinkMock::create([
      'id' => 'test.example9',
      'parent' => '',
    ])->setCurrentUser($this->currentUser),
  ];
  $this->originalTree = [];
  $this->originalTree[1] = new MenuLinkTreeElement($this->links[1], FALSE, 1, FALSE, []);
  $this->originalTree[2] = new MenuLinkTreeElement($this->links[2], TRUE, 1, FALSE, [
    3 => new MenuLinkTreeElement($this->links[3], TRUE, 2, FALSE, [
      4 => new MenuLinkTreeElement($this->links[4], FALSE, 3, FALSE, []),
    ]),
  ]);
  $this->originalTree[5] = new MenuLinkTreeElement($this->links[5], TRUE, 1, FALSE, [
    7 => new MenuLinkTreeElement($this->links[7], FALSE, 2, FALSE, []),
  ]);
  $this->originalTree[6] = new MenuLinkTreeElement($this->links[6], FALSE, 1, FALSE, []);
  $this->originalTree[8] = new MenuLinkTreeElement($this->links[8], FALSE, 1, FALSE, []);
  $this->originalTree[9] = new MenuLinkTreeElement($this->links[9], FALSE, 1, FALSE, []);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.