function ShortcutLinksTest::testNoShortcutLink
Same name in other branches
- 9 core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::testNoShortcutLink()
- 8.9.x core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\ShortcutLinksTest::testNoShortcutLink()
- 10 core/modules/shortcut/tests/src/Functional/ShortcutLinksTest.php \Drupal\Tests\shortcut\Functional\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
-
core/
modules/ shortcut/ tests/ src/ Functional/ ShortcutLinksTest.php, line 339
Class
- ShortcutLinksTest
- Create, view, edit, delete, and change shortcut links.
Namespace
Drupal\Tests\shortcut\FunctionalCode
public function testNoShortcutLink() : void {
// Change to a theme that displays shortcuts.
\Drupal::service('theme_installer')->install([
'claro',
]);
$this->config('system.theme')
->set('default', 'claro')
->save();
$this->drupalGet('page-that-does-not-exist');
// Test that add to shortcuts link is not shown on a page not found.
$this->assertSession()
->elementNotExists('xpath', '//a[contains(@class, "shortcut-action--add")]');
// The user does not have access to this path.
$this->drupalGet('admin/modules');
$this->assertSession()
->elementNotExists('xpath', '//a[contains(@class, "shortcut-action--add")]');
// Verify that the testing mechanism works by verifying the shortcut link
// appears on admin/content.
$this->drupalGet('admin/content');
$this->assertSession()
->elementExists('xpath', '//a[contains(@class, "shortcut-action--remove")]');
// Verify that the shortcut link appears on routing only pages.
$this->drupalGet('router_test/test2');
$this->assertSession()
->elementExists('xpath', '//a[contains(@class, "shortcut-action--add")]');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.