You are here

public function MultilingualTest::testCanNotAccess 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::testCanNotAccess()

File

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

Class

MultilingualTest
@group permissions_by_term

Namespace

Drupal\Tests\permissions_by_term\Kernel

Code

public function testCanNotAccess() {
  list($termDe, $nodeDe, $term, $node, $user) = $this
    ->setupEntities();
  $this->accessStorage
    ->addTermPermissionsByUserIds([
    \Drupal::service('current_user')
      ->id(),
  ], $term
    ->id(), 'en');
  $this->accessStorage
    ->addTermPermissionsByUserIds([
    $user
      ->id(),
  ], $termDe
    ->id(), 'de');

  /**
   * @var User $user
   */
  $user = user_load_by_name('some_username123');
  $this
    ->assertTrue($this->accessCheck
    ->canUserAccessByNodeId($node
    ->id(), \Drupal::service('current_user')
    ->id()));
  $this
    ->assertFalse($this->accessCheck
    ->canUserAccessByNodeId($nodeDe
    ->id(), \Drupal::service('current_user')
    ->id(), 'de'));
  $this
    ->assertTrue($this->accessCheck
    ->canUserAccessByNodeId($nodeDe
    ->id(), $user
    ->id(), 'de'));
}