protected function FieldPermissionsNodeTest::setNodeFieldPermissions in Field Permissions 8
Same name and namespace in other branches
- 8.2 tests/src/Functional/FieldPermissionsNodeTest.php \Drupal\Tests\field_permissions\Functional\FieldPermissionsNodeTest::setNodeFieldPermissions()
Set the bode body field permissions to the given type.
@todo Directly set the field permissions rather than using the UI.
Parameters
string $perm: The permission type.
array $custom_permission: An array of custom permissions.
4 calls to FieldPermissionsNodeTest::setNodeFieldPermissions()
- FieldPermissionsNodeTest::checkChengeToPrivateField in tests/
src/ Functional/ FieldPermissionsNodeTest.php - Test PUBLIC - PRIVATE EDIT - VIEW.
- FieldPermissionsNodeTest::checkViewEditAllField in tests/
src/ Functional/ FieldPermissionsNodeTest.php - Test - view edit all field.
- FieldPermissionsNodeTest::checkViewEditOwnField in tests/
src/ Functional/ FieldPermissionsNodeTest.php - Test PUBLIC - view own field.
- FieldPermissionsNodeTest::checkViewOwnField in tests/
src/ Functional/ FieldPermissionsNodeTest.php - Test PUBLIC - view own field.
File
- tests/
src/ Functional/ FieldPermissionsNodeTest.php, line 53
Class
- FieldPermissionsNodeTest
- Test field permissions on nodes.
Namespace
Drupal\Tests\field_permissions\FunctionalCode
protected function setNodeFieldPermissions($perm, array $custom_permission = []) {
$current_user = $this->loggedInUser;
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('admin/structure/types/manage/article/fields/node.article.body');
if ($perm === FieldPermissionTypeInterface::ACCESS_PUBLIC || $perm === FieldPermissionTypeInterface::ACCESS_PRIVATE) {
$edit = [
'type' => $perm,
];
$this
->submitForm($edit, 'Save settings');
}
elseif ($perm === FieldPermissionTypeInterface::ACCESS_CUSTOM && !empty($custom_permission)) {
$custom_permission['type'] = $perm;
$this
->submitForm($custom_permission, 'Save settings');
}
if ($current_user) {
$this
->drupalLogin($current_user);
}
}