You are here

protected function BreadcrumbFrontCacheContextsTest::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 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();
}