public function SystemMenuBlockTest::testConfigExpanded in Drupal 9
Same name and namespace in other branches
- 8 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 = isset($block_build['#items']) ? $block_build['#items'] : [];
$this
->assertEquals($expected_items, $this
->convertBuiltMenuToIdTree($items));
}