You are here

function AdminMenuCustomizedTest::testCustomExternal in Administration menu 8.3

Tests external links.

File

lib/Drupal/admin_menu/Tests/AdminMenuCustomizedTest.php, line 71

Class

AdminMenuCustomizedTest
Tests customized menu links.

Namespace

Drupal\admin_menu\Tests

Code

function testCustomExternal() {

  // Add a custom link to the node to the menu.
  $edit = [
    'link_path' => 'http://example.com',
    'link_title' => 'Example',
    'parent' => 'admin:' . $this
      ->queryMlidByPath('admin'),
  ];
  $this
    ->drupalPost('admin/structure/menu/manage/admin/add', $edit, t('Save'));

  // Verify that the link appears in the menu.
  $this
    ->drupalGet('');
  $elements = $this
    ->xpath('//div[@id=:id]//a[@href=:href and contains(text(), :text)]', [
    ':id' => 'admin-menu',
    ':href' => $edit['link_path'],
    ':text' => $edit['link_title'],
  ]);
  $this
    ->assertTrue($elements, 'External link found.');
}