You are here

function MenuTest::addCustomMenuCRUD 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::addCustomMenuCRUD()

Adds a custom menu using CRUD functions.

1 call to MenuTest::addCustomMenuCRUD()
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 155
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 addCustomMenuCRUD() {

  // Add a new custom menu.
  $menu_name = substr(hash('sha256', $this
    ->randomMachineName(16)), 0, MENU_MAX_MENU_NAME_LENGTH_UI);
  $label = $this
    ->randomMachineName(16);
  $menu = entity_create('menu', array(
    'id' => $menu_name,
    'label' => $label,
    'description' => 'Description text',
  ));
  $menu
    ->save();

  // Assert the new menu.
  $this
    ->drupalGet('admin/structure/menu/manage/' . $menu_name);
  $this
    ->assertRaw($label, 'Custom menu was added.');

  // Edit the menu.
  $new_label = $this
    ->randomMachineName(16);
  $menu
    ->set('label', $new_label);
  $menu
    ->save();
  $this
    ->drupalGet('admin/structure/menu/manage/' . $menu_name);
  $this
    ->assertRaw($new_label, 'Custom menu was edited.');
}