1 admin_bar.test AdminBarCustomizedTestCase::testCustomExternal()

Tests external links.

File

core/modules/admin_bar/tests/admin_bar.test, line 497
Tests for the Administration bar module.

Class

AdminBarCustomizedTestCase
Tests customized menu links.

Code

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

  // Verify that the link appears in the menu.
  $cid = 'admin_bar:' . $this->admin_user->uid . ':' . session_id() . ':en';
  $hash = admin_bar_cache_get($cid);
  $this->backdropGet('js/admin_bar/cache/' . $hash);
  $elements = $this->xpath('//div[@id=:id]//a[@href=:href]//*[contains(text(), :text)]', array(
    ':id' => 'admin-bar',
    ':href' => $edit['link_path'],
    ':text' => $edit['link_title'],
  ));
  $this->assertTrue($elements, 'External link found.');
}