You are here

function AdminMenuLinkTypesTest::testLinkTypes in Administration menu 8.3

Tests appearance of different router item link types.

File

lib/Drupal/admin_menu/Tests/AdminMenuLinkTypesTest.php, line 29

Class

AdminMenuLinkTypesTest
Tests appearance of different types of links.

Namespace

Drupal\admin_menu\Tests

Code

function testLinkTypes() {

  // Verify that MENU_NORMAL_ITEMs appear.
  $this
    ->assertLinkTrailByTitle([
    t('Configuration'),
    t('System'),
    t('Site information'),
  ]);

  // Verify that MENU_LOCAL_TASKs appear.
  $this
    ->assertLinkTrailByTitle([
    t('People'),
    t('Permissions'),
  ]);
  $this
    ->assertLinkTrailByTitle([
    t('Appearance'),
    t('Settings'),
  ]);
  $this
    ->assertLinkTrailByTitle([
    t('Extend'),
    t('Uninstall'),
  ]);

  // Verify that MENU_LOCAL_ACTIONs appear.
  $this
    ->assertLinkTrailByTitle([
    t('People'),
    t('Add user'),
  ]);

  // Verify that MENU_DEFAULT_LOCAL_TASKs do NOT appear.
  $this
    ->assertNoLinkTrailByTitle([
    t('Extend'),
    t('List'),
  ]);
  $this
    ->assertNoLinkTrailByTitle([
    t('People'),
    t('List'),
  ]);
  $this
    ->assertNoLinkTrailByTitle([
    t('People'),
    t('Permissions'),
    t('Permissions'),
  ]);
  $this
    ->assertNoLinkTrailByTitle([
    t('Appearance'),
    t('List'),
  ]);

  // Verify that MENU_VISIBLE_IN_BREADCRUMB items (exact type) do NOT appear.
  $this
    ->assertNoLinkTrailByTitle([
    t('Extend'),
    t('Uninstall'),
    t('Uninstall'),
  ]);
  $this
    ->assertNoLinkTrailByTitle([
    t('Help'),
    'admin_menu',
  ]);

  // Verify that special "Index" link appears below icon.
  $this
    ->assertElementByXPath('//div[@id="admin-menu"]//a[contains(@href, :path) and text()=:title]', [
    ':path' => 'admin/index',
    ':title' => t('Index'),
  ], "Icon » Index link found.");
}