function MenuUiTest::verifyMenuLink

Same name in other branches
  1. 8.9.x core/modules/menu_ui/tests/src/Functional/MenuUiTest.php \Drupal\Tests\menu_ui\Functional\MenuUiTest::verifyMenuLink()
  2. 10 core/modules/menu_ui/tests/src/Functional/MenuUiTest.php \Drupal\Tests\menu_ui\Functional\MenuUiTest::verifyMenuLink()
  3. 11.x 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::testMenuAdministration 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 798

Class

MenuUiTest
Tests the menu 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.
        $this->clickLink($title);
        $title = $parent_node->label();
        $this->assertSession()
            ->titleEquals("{$title} | Drupal");
    }
    // Verify menu link.
    $title = $item->getTitle();
    $this->assertSession()
        ->linkExists($title, 0, 'Menu link was displayed');
    // Verify menu link.
    $this->clickLink($title);
    $title = $item_node->label();
    $this->assertSession()
        ->titleEquals("{$title} | Drupal");
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.