You are here

protected function PathElementFormTest::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Element/PathElementFormTest.php \Drupal\KernelTests\Core\Element\PathElementFormTest::setUp()

Sets up the test.

Overrides KernelTestBase::setUp

File

core/tests/Drupal/KernelTests/Core/Element/PathElementFormTest.php, line 38

Class

PathElementFormTest
Tests PathElement validation and conversion functionality.

Namespace

Drupal\KernelTests\Core\Element

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->installSchema('system', [
    'sequences',
  ]);
  $this
    ->installEntitySchema('user');

  /** @var \Drupal\user\RoleInterface $role */
  $role = Role::create([
    'id' => 'admin',
    'label' => 'admin',
  ]);
  $role
    ->grantPermission('link to any page');
  $role
    ->save();
  $this->testUser = User::create([
    'name' => 'foobar',
    'mail' => 'foobar@example.com',
  ]);
  $this->testUser
    ->addRole($role
    ->id());
  $this->testUser
    ->save();
  \Drupal::service('current_user')
    ->setAccount($this->testUser);
}