function UserEntityReferenceTest::setUp

Same name in other branches
  1. 9 core/modules/user/tests/src/Kernel/UserEntityReferenceTest.php \Drupal\Tests\user\Kernel\UserEntityReferenceTest::setUp()
  2. 8.9.x core/modules/user/tests/src/Kernel/UserEntityReferenceTest.php \Drupal\Tests\user\Kernel\UserEntityReferenceTest::setUp()
  3. 10 core/modules/user/tests/src/Kernel/UserEntityReferenceTest.php \Drupal\Tests\user\Kernel\UserEntityReferenceTest::setUp()

Overrides EntityKernelTestBase::setUp

File

core/modules/user/tests/src/Kernel/UserEntityReferenceTest.php, line 38

Class

UserEntityReferenceTest
Tests the user reference field functionality.

Namespace

Drupal\Tests\user\Kernel

Code

protected function setUp() : void {
    parent::setUp();
    $this->role1 = Role::create([
        'id' => $this->randomMachineName(8),
        'label' => $this->randomMachineName(8),
    ]);
    $this->role1
        ->save();
    $this->role2 = Role::create([
        'id' => $this->randomMachineName(8),
        'label' => $this->randomMachineName(8),
    ]);
    $this->role2
        ->save();
    $this->createEntityReferenceField('user', 'user', 'user_reference', 'User reference', 'user');
}

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