class MenuDeleteTest
Tests the menu_delete hook.
@group menu_ui
Hierarchy
- class \Drupal\Tests\menu_ui\Kernel\MenuDeleteTest
Expanded class hierarchy of MenuDeleteTest
File
-
core/
modules/ menu_ui/ tests/ src/ Kernel/ MenuDeleteTest.php, line 17
Namespace
Drupal\Tests\menu_ui\KernelView source
class MenuDeleteTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'node',
'menu_ui',
'system',
];
/**
* @covers \Drupal\menu_ui\Hook\MenuUiHooks::menuDelete
* @dataProvider providerMenuDelete
*/
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'));
}
/**
* Provides data for testMenuDelete().
*/
public static function providerMenuDelete() : array {
return [
[
[
'available_menus' => [
'mock',
],
'parent' => 'mock:',
],
[
'available_menus' => [],
'parent' => '',
],
],
[
[
'available_menus' => [
'mock',
],
'parent' => 'mock:menu_link_content:e0cd7689-016e-43e4-af8f-7ce82801ab95',
],
[
'available_menus' => [],
'parent' => '',
],
],
[
[
'available_menus' => [
'main',
'mock',
],
'parent' => 'mock:',
],
[
'available_menus' => [
'main',
],
'parent' => '',
],
],
[
[
'available_menus' => [
'main',
],
'parent' => 'main:',
],
[
'available_menus' => [
'main',
],
'parent' => 'main:',
],
],
[
[
'available_menus' => [
'main',
],
'parent' => 'main:menu_link_content:e0cd7689-016e-43e4-af8f-7ce82801ab95',
],
[
'available_menus' => [
'main',
],
'parent' => 'main:menu_link_content:e0cd7689-016e-43e4-af8f-7ce82801ab95',
],
],
];
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
ExpectDeprecationTrait::expectDeprecation | public | function | Adds an expected deprecation. |
ExpectDeprecationTrait::setUpErrorHandler | public | function | Sets up the test error handler. |
ExpectDeprecationTrait::tearDownErrorHandler | public | function | Tears down the test error handler. |
MenuDeleteTest::$modules | protected static | property | Modules to install. |
MenuDeleteTest::providerMenuDelete | public static | function | Provides data for testMenuDelete(). |
MenuDeleteTest::testMenuDelete | public | function | @covers \Drupal\menu_ui\Hook\MenuUiHooks::menuDelete[[api-linebreak]] @dataProvider providerMenuDelete |
StorageCopyTrait::replaceStorageContents | protected static | function | Copy the configuration from one storage to another and remove stale items. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.