function MenuLinkContentFormTest::testMenuLinkContentForm

Same name in other branches
  1. 9 core/modules/menu_link_content/tests/src/Functional/MenuLinkContentFormTest.php \Drupal\Tests\menu_link_content\Functional\MenuLinkContentFormTest::testMenuLinkContentForm()
  2. 8.9.x core/modules/menu_link_content/tests/src/Functional/MenuLinkContentFormTest.php \Drupal\Tests\menu_link_content\Functional\MenuLinkContentFormTest::testMenuLinkContentForm()
  3. 11.x core/modules/menu_link_content/tests/src/Functional/MenuLinkContentFormTest.php \Drupal\Tests\menu_link_content\Functional\MenuLinkContentFormTest::testMenuLinkContentForm()

Tests the MenuLinkContentForm class.

File

core/modules/menu_link_content/tests/src/Functional/MenuLinkContentFormTest.php, line 87

Class

MenuLinkContentFormTest
Tests the menu link content UI.

Namespace

Drupal\Tests\menu_link_content\Functional

Code

public function testMenuLinkContentForm() : void {
    $this->drupalGet('admin/structure/menu/manage/admin/add');
    // Test that other menus are not available when creating a new menu link.
    $this->assertSession()
        ->optionNotExists('edit-menu-parent', 'main:');
    $option = $this->assertSession()
        ->optionExists('edit-menu-parent', 'admin:');
    $this->assertTrue($option->isSelected());
    // Test that the field description is present.
    $this->assertSession()
        ->pageTextContains('The location this menu link points to.');
    $this->submitForm([
        'title[0][value]' => 'Front page',
        'link[0][uri]' => '<front>',
    ], 'Save');
    $this->assertSession()
        ->pageTextContains('The menu link has been saved.');
}

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