public function TrustedHostsTest::testShortcut in Drupal 9
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Functional/System/TrustedHostsTest.php \Drupal\Tests\system\Functional\System\TrustedHostsTest::testShortcut()
Tests that shortcut module works together with host verification.
File
- core/
modules/ system/ tests/ src/ Functional/ System/ TrustedHostsTest.php, line 86
Class
- TrustedHostsTest
- Tests output on the status overview page.
Namespace
Drupal\Tests\system\Functional\SystemCode
public function testShortcut() {
$this->container
->get('module_installer')
->install([
'block',
'shortcut',
]);
$this
->rebuildContainer();
/** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
$entity_type_manager = $this->container
->get('entity_type.manager');
$shortcut_storage = $entity_type_manager
->getStorage('shortcut');
$shortcut = $shortcut_storage
->create([
'title' => $this
->randomString(),
'link' => 'internal:/admin/reports/status',
'shortcut_set' => 'default',
]);
$shortcut_storage
->save($shortcut);
// Grant the current user access to see the shortcuts.
$role_storage = $entity_type_manager
->getStorage('user_role');
$roles = $this->loggedInUser
->getRoles(TRUE);
/** @var \Drupal\user\RoleInterface $role */
$role = $role_storage
->load(reset($roles));
$role
->grantPermission('access shortcuts')
->save();
$this
->drupalPlaceBlock('shortcuts');
$this
->drupalGet('');
$this
->assertSession()
->linkExists($shortcut
->label());
}