function ShortcutTestBase::setUp
Same name in other branches
- 9 core/modules/shortcut/tests/src/Functional/ShortcutTestBase.php \Drupal\Tests\shortcut\Functional\ShortcutTestBase::setUp()
- 8.9.x core/modules/shortcut/src/Tests/ShortcutTestBase.php \Drupal\shortcut\Tests\ShortcutTestBase::setUp()
- 8.9.x core/modules/shortcut/tests/src/Functional/ShortcutTestBase.php \Drupal\Tests\shortcut\Functional\ShortcutTestBase::setUp()
- 10 core/modules/shortcut/tests/src/Functional/ShortcutTestBase.php \Drupal\Tests\shortcut\Functional\ShortcutTestBase::setUp()
Overrides BrowserTestBase::setUp
2 calls to ShortcutTestBase::setUp()
- ShortcutLinksTest::setUp in core/
modules/ shortcut/ tests/ src/ Functional/ ShortcutLinksTest.php - ShortcutSetsTest::setUp in core/
modules/ shortcut/ tests/ src/ Functional/ ShortcutSetsTest.php
2 methods override ShortcutTestBase::setUp()
- ShortcutLinksTest::setUp in core/
modules/ shortcut/ tests/ src/ Functional/ ShortcutLinksTest.php - ShortcutSetsTest::setUp in core/
modules/ shortcut/ tests/ src/ Functional/ ShortcutSetsTest.php
File
-
core/
modules/ shortcut/ tests/ src/ Functional/ ShortcutTestBase.php, line 53
Class
- ShortcutTestBase
- Defines base class for shortcut test cases.
Namespace
Drupal\Tests\shortcut\FunctionalCode
protected function setUp() : void {
parent::setUp();
if ($this->profile != 'standard') {
// Create Basic page and Article node types.
$this->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page',
]);
$this->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
]);
// Populate the default shortcut set.
$shortcut = Shortcut::create([
'shortcut_set' => 'default',
'title' => 'Add content',
'weight' => -20,
'link' => [
'uri' => 'internal:/node/add',
],
]);
$shortcut->save();
$shortcut = Shortcut::create([
'shortcut_set' => 'default',
'title' => 'All content',
'weight' => -19,
'link' => [
'uri' => 'internal:/admin/content',
],
]);
$shortcut->save();
}
// Create users.
$this->adminUser = $this->drupalCreateUser([
'access toolbar',
'administer shortcuts',
'view the administration theme',
'create article content',
'create page content',
'access content overview',
'administer users',
'link to any page',
'edit any article content',
]);
$this->shortcutUser = $this->drupalCreateUser([
'customize shortcut links',
'switch shortcut sets',
'access shortcuts',
'access content',
]);
// Create a node.
$this->node = $this->drupalCreateNode([
'type' => 'article',
]);
// Log in as admin and grab the default shortcut set.
$this->drupalLogin($this->adminUser);
$this->set = ShortcutSet::load('default');
\Drupal::entityTypeManager()->getStorage('shortcut_set')
->assignUser($this->set, $this->adminUser);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.