You are here

public function MenuTreeStorageTest::testSimpleHierarchy in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Menu/MenuTreeStorageTest.php \Drupal\system\Tests\Menu\MenuTreeStorageTest::testSimpleHierarchy()

Tests with a simple linear hierarchy.

File

core/modules/system/src/Tests/Menu/MenuTreeStorageTest.php, line 85
Contains \Drupal\system\Tests\Menu\MenuTreeStorageTest.

Class

MenuTreeStorageTest
Tests the menu tree storage.

Namespace

Drupal\system\Tests\Menu

Code

public function testSimpleHierarchy() {

  // Add some links with parent on the previous one and test some values.
  // <tools>
  // - test1
  // -- test2
  // --- test3
  $this
    ->addMenuLink('test1', '');
  $this
    ->assertMenuLink('test1', array(
    'has_children' => 0,
    'depth' => 1,
  ));
  $this
    ->addMenuLink('test2', 'test1');
  $this
    ->assertMenuLink('test1', array(
    'has_children' => 1,
    'depth' => 1,
  ), array(), array(
    'test2',
  ));
  $this
    ->assertMenuLink('test2', array(
    'has_children' => 0,
    'depth' => 2,
  ), array(
    'test1',
  ));
  $this
    ->addMenuLink('test3', 'test2');
  $this
    ->assertMenuLink('test1', array(
    'has_children' => 1,
    'depth' => 1,
  ), array(), array(
    'test2',
    'test3',
  ));
  $this
    ->assertMenuLink('test2', array(
    'has_children' => 1,
    'depth' => 2,
  ), array(
    'test1',
  ), array(
    'test3',
  ));
  $this
    ->assertMenuLink('test3', array(
    'has_children' => 0,
    'depth' => 3,
  ), array(
    'test2',
    'test1',
  ));
}