You are here

function MenuTest::deleteCustomMenu in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/menu_ui/src/Tests/MenuTest.php \Drupal\menu_ui\Tests\MenuTest::deleteCustomMenu()

Deletes the locally stored custom menu.

This deletes the custom menu that is stored in $this->menu and performs tests on the menu delete user interface.

1 call to MenuTest::deleteCustomMenu()
MenuTest::testMenu in core/modules/menu_ui/src/Tests/MenuTest.php
Tests menu functionality using the admin and user interfaces.

File

core/modules/menu_ui/src/Tests/MenuTest.php, line 238
Contains \Drupal\menu_ui\Tests\MenuTest.

Class

MenuTest
Add a custom menu, add menu links to the custom menu and Tools menu, check their data, and delete them using the UI.

Namespace

Drupal\menu_ui\Tests

Code

function deleteCustomMenu() {
  $menu_name = $this->menu
    ->id();
  $label = $this->menu
    ->label();

  // Delete custom menu.
  $this
    ->drupalPostForm("admin/structure/menu/manage/{$menu_name}/delete", array(), t('Delete'));
  $this
    ->assertResponse(200);
  $this
    ->assertRaw(t('The menu %title has been deleted.', array(
    '%title' => $label,
  )), 'Custom menu was deleted');
  $this
    ->assertNull(Menu::load($menu_name), 'Custom menu was deleted');

  // Test if all menu links associated with the menu were removed from
  // database.
  $result = entity_load_multiple_by_properties('menu_link_content', array(
    'menu_name' => $menu_name,
  ));
  $this
    ->assertFalse($result, 'All menu links associated with the custom menu were deleted.');

  // Make sure there's no delete button on system menus.
  $this
    ->drupalGet('admin/structure/menu/manage/main');
  $this
    ->assertNoRaw('edit-delete', 'The delete button was not found');

  // Try to delete the main menu.
  $this
    ->drupalGet('admin/structure/menu/manage/main/delete');
  $this
    ->assertText(t('You are not authorized to access this page.'));
}