You are here

public function MultilingualTest::testCanAccess in Permissions by Term 8

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/MultilingualTest.php \Drupal\Tests\permissions_by_term\Kernel\MultilingualTest::testCanAccess()

File

tests/src/Kernel/MultilingualTest.php, line 33

Class

MultilingualTest
@group permissions_by_term

Namespace

Drupal\Tests\permissions_by_term\Kernel

Code

public function testCanAccess() {
  Vocabulary::create([
    'name' => 'Test Multilingual',
    'vid' => 'test_multilingual',
    'langcode' => 'de',
  ])
    ->save();
  $term = Term::create([
    'name' => 'term1',
    'vid' => 'test',
    'langcode' => 'de',
  ]);
  $term
    ->save();
  $node = Node::create([
    'type' => 'page',
    'title' => 'test_title',
    'field_tags' => [
      [
        'target_id' => $term
          ->id(),
      ],
    ],
  ]);
  $node
    ->save();
  $this->accessStorage
    ->addTermPermissionsByUserIds([
    \Drupal::service('current_user')
      ->id(),
  ], $term
    ->id(), 'de');
  $this
    ->assertTrue($this->accessCheck
    ->canUserAccessByNodeId($node
    ->id()));
}