public function ShortcutLinksTest::testNoShortcutLink in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/shortcut/src/Tests/ShortcutLinksTest.php \Drupal\shortcut\Tests\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/ src/ Tests/ ShortcutLinksTest.php, line 275 - Contains \Drupal\shortcut\Tests\ShortcutLinksTest.
Class
- ShortcutLinksTest
- Create, view, edit, delete, and change shortcut links.
Namespace
Drupal\shortcut\TestsCode
public function testNoShortcutLink() {
// Change to a theme that displays shortcuts.
\Drupal::service('theme_handler')
->install(array(
'seven',
));
$this
->config('system.theme')
->set('default', 'seven')
->save();
$this
->drupalGet('page-that-does-not-exist');
$result = $this
->xpath('//a[contains(@class, "shortcut-action--add")]');
$this
->assertTrue(empty($result), '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');
$result = $this
->xpath('//a[contains(@class, "shortcut-action--add")]');
$this
->assertTrue(empty($result), '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.
$this
->drupalGet('admin/content');
$result = $this
->xpath('//a[contains(@class, "shortcut-action--remove")]');
$this
->assertTrue(!empty($result), 'Remove from shortcuts link was shown on a page the user does have access to.');
// Verify that the shortcut link appears on routing only pages.
$this
->drupalGet('router_test/test2');
$result = $this
->xpath('//a[contains(@class, "shortcut-action--add")]');
$this
->assertTrue(!empty($result), 'Add to shortcuts link was shown on a page the user does have access to.');
}