You are here

protected function UserMatcherTest::setUp in Linkit 8.5

Overrides LinkitKernelTestBase::setUp

File

tests/src/Kernel/Matchers/UserMatcherTest.php, line 25

Class

UserMatcherTest
Tests user matcher.

Namespace

Drupal\Tests\linkit\Kernel\Matchers

Code

protected function setUp() {
  parent::setUp();

  // Create user 1 who has special permissions.
  $this
    ->createUser();
  \Drupal::currentUser()
    ->setAccount($this
    ->createUser([], [
    'access user profiles',
  ]));
  $this->manager = $this->container
    ->get('plugin.manager.linkit.matcher');
  $custom_role = Role::create([
    'id' => 'custom_role',
    'label' => 'custom_role',
  ]);
  $custom_role
    ->save();
  $custom_role_admin = Role::create([
    'id' => 'custom_role_admin',
    'label' => 'custom_role_admin',
  ]);
  $custom_role_admin
    ->save();
  $this
    ->createUser([
    'name' => 'lorem',
  ]);
  $this
    ->createUser([
    'name' => 'foo',
  ]);
  $account = $this
    ->createUser([
    'name' => 'ipsumlorem',
  ]);
  $account
    ->addRole($custom_role);
  $account
    ->save();
  $account = $this
    ->createUser([
    'name' => 'lorem_custom_role',
  ]);
  $account
    ->addRole($custom_role);
  $account
    ->save();
  $account = $this
    ->createUser([
    'name' => 'lorem_custom_role_admin',
  ]);
  $account
    ->addRole($custom_role_admin);
  $account
    ->save();
  $account = $this
    ->createUser([
    'name' => 'blocked_lorem',
  ]);
  $account
    ->block();
  $account
    ->save();
}