You are here

protected function MenuPerRoleAccessTest::setUp in Menu Per Role 8

Throws

\Drupal\Core\Entity\EntityStorageException

Overrides MenuPerRoleFunctionalTestBase::setUp

File

tests/src/Functional/MenuPerRoleAccessTest.php, line 160

Class

MenuPerRoleAccessTest
Test access control to menu links.

Namespace

Drupal\Tests\menu_per_role\Functional

Code

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

  // User1.
  $user1Role = $this
    ->drupalCreateRole($this->user1Permissions, $this->user1Role);
  $this->user1 = $this
    ->drupalCreateUser([], 'user1');
  $this->user1
    ->addRole($user1Role);
  $this->user1
    ->save();

  // User2.
  $user2Role = $this
    ->drupalCreateRole($this->user2Permissions, $this->user2Role);
  $this->user2 = $this
    ->drupalCreateUser([], 'user2');
  $this->user2
    ->addRole($user2Role);
  $this->user2
    ->save();

  // User3.
  $user3Role = $this
    ->drupalCreateRole($this->user3Permissions, $this->user3Role);
  $this->user3 = $this
    ->drupalCreateUser([], 'user3');
  $this->user3
    ->addRole($user3Role);
  $this->user3
    ->save();

  // User4.
  $user4Role = $this
    ->drupalCreateRole($this->user4Permissions, $this->user4Role);
  $this->user4 = $this
    ->drupalCreateUser([], 'user4');
  $this->user4
    ->addRole($user4Role);
  $this->user4
    ->save();

  // Admin.
  $adminRole = $this
    ->drupalCreateRole($this->adminPermissions, $this->adminRole);
  $this->admin = $this
    ->drupalCreateUser([], 'admin_menu_per_role', TRUE);
  $this->admin
    ->addRole($adminRole);
  $this->admin
    ->save();
}