You are here

protected function FieldPermissionsUserTest::checkUserViewEditField in Field Permissions 8.2

Same name and namespace in other branches
  1. 8 tests/src/Functional/FieldPermissionsUserTest.php \Drupal\Tests\field_permissions\Functional\FieldPermissionsUserTest::checkUserViewEditField()

Tests custom permissions.

1 call to FieldPermissionsUserTest::checkUserViewEditField()
FieldPermissionsUserTest::testUserFieldPermissions in tests/src/Functional/FieldPermissionsUserTest.php
Test field permissions on user entities.

File

tests/src/Functional/FieldPermissionsUserTest.php, line 231

Class

FieldPermissionsUserTest
Test field permissions on users.

Namespace

Drupal\Tests\field_permissions\Functional

Code

protected function checkUserViewEditField() {
  $permission = [];

  // AGGIUNGE I PERMESSI DI VIEW_OWN. all'utente limitato.
  $this
    ->drupalLogin($this->webUser);
  $perm = [
    'view ' . $this->fieldName,
  ];
  $permission = $this
    ->grantCustomPermissions($this->webUserRole, $perm, $permission);
  $this
    ->setUserFieldPermission(FieldPermissionTypeInterface::ACCESS_CUSTOM, $permission);
  $this
    ->assertUserFieldAccess($this->limitedUser);
  $perm = [
    'edit ' . $this->fieldName,
  ];
  $permission = $this
    ->grantCustomPermissions($this->webUserRole, $perm, $permission);
  $this
    ->setUserFieldPermission(FieldPermissionTypeInterface::ACCESS_CUSTOM, $permission);
  $this
    ->assertUserEditFieldAccess($this->limitedUser);
  $this
    ->drupalLogout();
}