public function ShortcutLinksTest::testNoShortcutLink in Drupal 9
Same name and namespace in other branches
- 8 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 316
Class
- ShortcutLinksTest
- Create, view, edit, delete, and change shortcut links.
Namespace
Drupal\Tests\shortcut\FunctionalCode
public function testNoShortcutLink() {
// Change to a theme that displays shortcuts.
\Drupal::service('theme_installer')
->install([
'seven',
]);
$this
->config('system.theme')
->set('default', 'seven')
->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")]');
}