You are here

protected function SystemMenuBlockTest::convertBuiltMenuToIdTree in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php \Drupal\Tests\system\Kernel\Block\SystemMenuBlockTest::convertBuiltMenuToIdTree()

Helper method to allow for easy menu link tree structure assertions.

Converts the result of MenuLinkTree::build() in a "menu link ID tree".

Parameters

array $build: The return value of MenuLinkTree::build()

Return value

array The "menu link ID tree" representation of the given render array.

2 calls to SystemMenuBlockTest::convertBuiltMenuToIdTree()
SystemMenuBlockTest::testConfigExpanded in core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php
Tests the config expanded option.
SystemMenuBlockTest::testConfigLevelDepth in core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php
Tests the config start level and depth.

File

core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php, line 382

Class

SystemMenuBlockTest
Tests \Drupal\system\Plugin\Block\SystemMenuBlock.

Namespace

Drupal\Tests\system\Kernel\Block

Code

protected function convertBuiltMenuToIdTree(array $build) {
  $level = [];
  foreach (Element::children($build) as $id) {
    $level[$id] = [];
    if (isset($build[$id]['below'])) {
      $level[$id] = $this
        ->convertBuiltMenuToIdTree($build[$id]['below']);
    }
  }
  return $level;
}