function BreadcrumbFrontCacheContextsTest::setUp

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/Menu/BreadcrumbFrontCacheContextsTest.php \Drupal\Tests\system\Functional\Menu\BreadcrumbFrontCacheContextsTest::setUp()
  2. 8.9.x core/modules/system/tests/src/Functional/Menu/BreadcrumbFrontCacheContextsTest.php \Drupal\Tests\system\Functional\Menu\BreadcrumbFrontCacheContextsTest::setUp()
  3. 11.x core/modules/system/tests/src/Functional/Menu/BreadcrumbFrontCacheContextsTest.php \Drupal\Tests\system\Functional\Menu\BreadcrumbFrontCacheContextsTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/system/tests/src/Functional/Menu/BreadcrumbFrontCacheContextsTest.php, line 43

Class

BreadcrumbFrontCacheContextsTest
Tests breadcrumbs functionality.

Namespace

Drupal\Tests\system\Functional\Menu

Code

protected function setUp() : void {
    parent::setUp();
    $this->drupalPlaceBlock('system_breadcrumb_block');
    $user = $this->drupalCreateUser();
    $this->drupalCreateContentType([
        'type' => 'page',
    ]);
    // Create a node for front page.
    $node_front = $this->drupalCreateNode([
        'uid' => $user->id(),
    ]);
    // Create a node with a random alias.
    $this->nodeWithAlias = $this->drupalCreateNode([
        'uid' => $user->id(),
        'type' => 'page',
        'path' => '/' . $this->randomMachineName(),
    ]);
    // Configure 'node' as front page.
    $this->config('system.site')
        ->set('page.front', '/node/' . $node_front->id())
        ->save();
    \Drupal::cache('render')->deleteAll();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.