You are here

public function ToolbarAdminMenuTest::testExternalLink in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/toolbar/src/Tests/ToolbarAdminMenuTest.php \Drupal\toolbar\Tests\ToolbarAdminMenuTest::testExternalLink()

Tests that external links added to the menu appear in the toolbar.

File

core/modules/toolbar/src/Tests/ToolbarAdminMenuTest.php, line 381
Contains \Drupal\toolbar\Tests\ToolbarAdminMenuTest.

Class

ToolbarAdminMenuTest
Tests the caching of the admin menu subtree items.

Namespace

Drupal\toolbar\Tests

Code

public function testExternalLink() {
  $edit = [
    'title[0][value]' => 'External URL',
    'link[0][uri]' => 'http://example.org',
    'menu_parent' => 'admin:system.admin',
    'description[0][value]' => 'External URL & escaped',
  ];
  $this
    ->drupalPostForm('admin/structure/menu/manage/admin/add', $edit, 'Save');

  // Assert that the new menu link is shown on the menu link listing.
  $this
    ->drupalGet('admin/structure/menu/manage/admin');
  $this
    ->assertText('External URL');

  // Assert that the new menu link is shown in the toolbar on a regular page.
  $this
    ->drupalGet(Url::fromRoute('<front>'));
  $this
    ->assertText('External URL');

  // Ensure the description is escaped as expected.
  $this
    ->assertRaw('title="External URL &amp; escaped"');
}