function ShortcutLinksTest::testNoShortcutLink

Tests that the add shortcut link is not displayed for 404/403 errors.

Tests that the "Add to shortcuts" link is not displayed on a page not found or a page the user does not have access to.

File

drupal/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php, line 123
Definition of Drupal\shortcut\Tests\ShortcutLinksTest.

Class

ShortcutLinksTest
Defines shortcut links test cases.

Namespace

Drupal\shortcut\Tests

Code

function testNoShortcutLink() {

  // Change to a theme that displays shortcuts.
  variable_set('theme_default', 'seven');
  $this
    ->drupalGet('page-that-does-not-exist');
  $this
    ->assertNoRaw('add-shortcut', 'Add to shortcuts link was not shown on a page not found.');

  // The user does not have access to this path.
  $this
    ->drupalGet('admin/modules');
  $this
    ->assertNoRaw('add-shortcut', 'Add to shortcuts link was not shown on a page the user does not have access to.');

  // Verify that the testing mechanism works by verifying the shortcut
  // link appears on admin/content/node.
  $this
    ->drupalGet('admin/content/node');
  $this
    ->assertRaw('add-shortcut', 'Add to shortcuts link was shown on a page the user does have access to.');
}