function MenuTest::deleteCustomMenu

Delete custom menu.

Parameters

string $menu_name Custom menu name.:

1 call to MenuTest::deleteCustomMenu()
MenuTest::testMenu in drupal/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php
Login users, add menus and menu links, and test menu functionality through the admin and user interfaces.

File

drupal/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php, line 176
Definition of Drupal\menu\Tests\MenuTest.

Class

MenuTest

Namespace

Drupal\menu\Tests

Code

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

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

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

  // Make sure there's no delete button on system menus.
  $this
    ->drupalGet('admin/structure/menu/manage/main/edit');
  $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.'));
}