You are here

public function MenuUiTest::verifyMenuLink in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/menu_ui/tests/src/Functional/MenuUiTest.php \Drupal\Tests\menu_ui\Functional\MenuUiTest::verifyMenuLink()

Verifies a menu link using the UI.

Parameters

\Drupal\menu_link_content\Entity\MenuLinkContent $item: Menu link.

object $item_node: Menu link content node.

\Drupal\menu_link_content\Entity\MenuLinkContent $parent: Parent menu link.

object $parent_node: Parent menu link content node.

2 calls to MenuUiTest::verifyMenuLink()
MenuUiTest::doMenuTests in core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
Tests menu functionality.
MenuUiTest::testMenu in core/modules/menu_ui/tests/src/Functional/MenuUiTest.php
Tests menu functionality using the admin and user interfaces.

File

core/modules/menu_ui/tests/src/Functional/MenuUiTest.php, line 709

Class

MenuUiTest
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\Tests\menu_ui\Functional

Code

public function verifyMenuLink(MenuLinkContent $item, $item_node, MenuLinkContent $parent = NULL, $parent_node = NULL) {

  // View home page.
  $this
    ->drupalGet('');
  $this
    ->assertSession()
    ->statusCodeEquals(200);

  // Verify parent menu link.
  if (isset($parent)) {

    // Verify menu link.
    $title = $parent
      ->getTitle();
    $this
      ->assertSession()
      ->linkExists($title, 0, 'Parent menu link was displayed');

    // Verify menu link link.
    $this
      ->clickLink($title);
    $title = $parent_node
      ->label();
    $this
      ->assertTitle("{$title} | Drupal");
  }

  // Verify menu link.
  $title = $item
    ->getTitle();
  $this
    ->assertSession()
    ->linkExists($title, 0, 'Menu link was displayed');

  // Verify menu link link.
  $this
    ->clickLink($title);
  $title = $item_node
    ->label();
  $this
    ->assertTitle("{$title} | Drupal");
}