function SystemMenuBlockTest::testIgnoreActiveTrailConstraint
Tests configuration schema validation for IgnoreActiveTrail constraint.
Attributes
#[DataProvider('providerIgnoreActiveTrailConstraint')]
File
-
core/
modules/ system/ tests/ src/ Kernel/ Block/ SystemMenuBlockTest.php, line 466
Class
Namespace
Drupal\Tests\system\Kernel\BlockCode
public function testIgnoreActiveTrailConstraint(int $level, int $depth, bool $expand_all_items, ?bool $ignore_active_trail, bool $expect_exception) : void {
if ($expect_exception) {
$this->expectException(SchemaIncompleteException::class);
$this->expectExceptionMessage('Schema errors for block.block.machine_name with the following errors: 0 [settings] The "ignore_active_trail" setting on a system menu block cannot be enabled if "level" is greater than 1 or "expand_all_items" is not enabled and "depth" is greater than 1.');
}
\Drupal::service('theme_installer')->install([
'stark',
]);
$settings = [
'label' => 'Menu block',
'level' => $level,
'depth' => $depth,
'expand_all_items' => $expand_all_items,
];
if ($ignore_active_trail) {
$settings['ignore_active_trail'] = TRUE;
}
/** @var \Drupal\block\BlockInterface $block */
$block = Block::create([
'id' => 'machine_name',
'theme' => 'stark',
'plugin' => 'system_menu_block:' . $this->menu
->id(),
'region' => 'footer',
'settings' => $settings,
]);
$block->save();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.