You are here

private function EntityAccessCheckTest::setupUsersAndTerms in Permissions by Term 8.2

Same name and namespace in other branches
  1. 8 modules/permissions_by_entity/tests/src/Kernel/EntityAccessCheckTest.php \Drupal\Tests\permissions_by_entity\Kernel\EntityAccessCheckTest::setupUsersAndTerms()

Configures users and connected terms.

1 call to EntityAccessCheckTest::setupUsersAndTerms()
EntityAccessCheckTest::setUp in modules/permissions_by_entity/tests/src/Kernel/EntityAccessCheckTest.php

File

modules/permissions_by_entity/tests/src/Kernel/EntityAccessCheckTest.php, line 165

Class

EntityAccessCheckTest
Class EntityAccessCheckTest

Namespace

Drupal\Tests\permissions_by_entity\Kernel

Code

private function setupUsersAndTerms() {
  Vocabulary::create([
    'name' => 'test',
    'vid' => 'test',
  ])
    ->save();

  # First user.
  $term_array['term_user_a']['user'] = User::create([
    'name' => 'term_user_a',
    'mail' => 'term_user_a@example.com',
  ]);
  $term_array['term_user_a']['user']
    ->save();
  $term_array['term_user_a']['term'] = Term::create([
    'name' => 'term_user_a',
    'vid' => 'test',
  ]);
  $term_array['term_user_a']['term']
    ->save();
  $this->accessStorage
    ->addTermPermissionsByUserIds([
    $term_array['term_user_a']['user']
      ->id(),
  ], $term_array['term_user_a']['term']
    ->id());

  # Second user.
  $term_array['term_user_b']['user'] = User::create([
    'name' => 'term_user_b',
    'mail' => 'term_user_b@example.com',
  ]);
  $term_array['term_user_b']['user']
    ->save();
  $term_array['term_user_b']['term'] = Term::create([
    'name' => 'term_user_b',
    'vid' => 'test',
  ]);
  $term_array['term_user_b']['term']
    ->save();
  $this->accessStorage
    ->addTermPermissionsByUserIds([
    $term_array['term_user_b']['user']
      ->id(),
  ], $term_array['term_user_b']['term']
    ->id());
  $this->terms = $term_array;
}