function MenuDeleteTest::testMenuDelete
@covers \Drupal\menu_ui\Hook\MenuUiHooks::menuDelete
@dataProvider providerMenuDelete
File
-
core/
modules/ menu_ui/ tests/ src/ Kernel/ MenuDeleteTest.php, line 28
Class
- MenuDeleteTest
- Tests the menu_delete hook.
Namespace
Drupal\Tests\menu_ui\KernelCode
public function testMenuDelete($settings, $expected) : void {
$menu = Menu::create([
'id' => 'mock',
'label' => $this->randomMachineName(16),
'description' => 'Description text',
]);
$menu->save();
$content_type = NodeType::create([
'status' => TRUE,
'dependencies' => [
'module' => [
'menu_ui',
],
],
'third_party_settings' => [
'menu_ui' => $settings,
],
'name' => 'Test type',
'type' => 'test_type',
]);
$content_type->save();
$this->assertEquals($settings['available_menus'], $content_type->getThirdPartySetting('menu_ui', 'available_menus'));
$this->assertEquals($settings['parent'], $content_type->getThirdPartySetting('menu_ui', 'parent'));
$hooks = new MenuUiHooks(\Drupal::entityTypeManager());
$hooks->menuDelete($menu);
$content_type = NodeType::load('test_type');
$this->assertEquals($expected['available_menus'], $content_type->getThirdPartySetting('menu_ui', 'available_menus'));
$this->assertEquals($expected['parent'], $content_type->getThirdPartySetting('menu_ui', 'parent'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.