protected function FieldPermissionsUserTest::checkUserViewEditOwnField in Field Permissions 8
Same name and namespace in other branches
- 8.2 tests/src/Functional/FieldPermissionsUserTest.php \Drupal\Tests\field_permissions\Functional\FieldPermissionsUserTest::checkUserViewEditOwnField()
Test PUBLIC - view_own and edit_own field.
1 call to FieldPermissionsUserTest::checkUserViewEditOwnField()
- FieldPermissionsUserTest::testUserFieldPermissions in tests/
src/ Functional/ FieldPermissionsUserTest.php - Test field permissions on user entities.
File
- tests/
src/ Functional/ FieldPermissionsUserTest.php, line 187
Class
- FieldPermissionsUserTest
- Test field permissions on users.
Namespace
Drupal\Tests\field_permissions\FunctionalCode
protected function checkUserViewEditOwnField() {
$permission = [];
// AGGIUNGE I PERMESSI DI VIEW_OWN. all'utente limitato.
$this
->drupalLogin($this->webUser);
$perm = [
'view own ' . $this->fieldName,
];
$permission = $this
->grantCustomPermissions($this->limitUserRole, $perm, $permission);
$this
->setUserFieldPermission(FieldPermissionTypeInterface::ACCESS_CUSTOM, $permission);
// [admin] view/edit profile limit user (false).
$this
->assertUserFieldNoAccess($this->limitedUser);
$this
->assertUserEditFieldNoAccess($this->limitedUser);
// [admin] view/edit your profile (false).
$this
->assertUserEditFieldNoAccess($this->adminUser);
$this
->assertUserFieldNoAccess($this->adminUser);
$this
->drupalLogout();
$this
->drupalLogin($this->limitedUser);
// [Limited user] view your profile (true).
$this
->assertUserFieldAccess($this->limitedUser);
// [Limited user] view admin profile (false).
$this
->assertUserFieldNoAccess($this->adminUser);
// [Limited user] edit your profile false.
$this
->assertUserEditFieldNoAccess($this->limitedUser);
$this
->drupalLogout();
// AGGIUNGE I PERMESSI DI EDIT_OWN to limitUserRole.
$this
->drupalLogin($this->webUser);
$permission = $this
->grantCustomPermissions($this->limitUserRole, [
'edit own ' . $this->fieldName,
], $permission);
$this
->setUserFieldPermission(FieldPermissionTypeInterface::ACCESS_CUSTOM, $permission);
// [admin] edit your profile (false).
$this
->assertUserEditFieldNoAccess($this->adminUser);
// [admin] edit limit profile (false).
$this
->assertUserEditFieldNoAccess($this->limitedUser);
$this
->drupalLogout();
$this
->drupalLogin($this->limitedUser);
// [Limited user] edit your profile (true).
$this
->assertUserEditFieldAccess($this->limitedUser);
$this
->drupalLogout();
}