function SystemMenuBlockTest::testConfigExpanded
Same name in other branches
- 8.9.x core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php \Drupal\Tests\system\Kernel\Block\SystemMenuBlockTest::testConfigExpanded()
- 10 core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php \Drupal\Tests\system\Kernel\Block\SystemMenuBlockTest::testConfigExpanded()
- 11.x core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php \Drupal\Tests\system\Kernel\Block\SystemMenuBlockTest::testConfigExpanded()
Tests the config expanded option.
@dataProvider configExpandedTestCases
File
-
core/
modules/ system/ tests/ src/ Kernel/ Block/ SystemMenuBlockTest.php, line 291
Class
Namespace
Drupal\Tests\system\Kernel\BlockCode
public function testConfigExpanded($active_route, $menu_block_level, $expected_items) {
$block = $this->blockManager
->createInstance('system_menu_block:' . $this->menu
->id(), [
'region' => 'footer',
'id' => 'machinename',
'theme' => 'stark',
'level' => $menu_block_level,
'depth' => 0,
'expand_all_items' => TRUE,
]);
$route = $this->container
->get('router.route_provider')
->getRouteByName($active_route);
$request = new Request();
$request->attributes
->set(RouteObjectInterface::ROUTE_NAME, $active_route);
$request->attributes
->set(RouteObjectInterface::ROUTE_OBJECT, $route);
$this->container
->get('request_stack')
->push($request);
$block_build = $block->build();
$items = $block_build['#items'] ?? [];
$this->assertEquals($expected_items, $this->convertBuiltMenuToIdTree($items));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.