You are here

protected function FieldPermissionsTestBase::grantCustomPermissions in Field Permissions 8

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/FieldPermissionsTestBase.php \Drupal\Tests\field_permissions\Functional\FieldPermissionsTestBase::grantCustomPermissions()

Appends existing permissions grid with new permissions.

Parameters

string $role: The role ID to grant permissions for.

array $new_permissions: An array of new permissions to grant.

array $existing_custom_permission: The existing custom permissions grid.

Return value

array The complete custom permissions matrix.

6 calls to FieldPermissionsTestBase::grantCustomPermissions()
FieldPermissionsCommentTest::checkCustomCommentField in tests/src/Functional/FieldPermissionsCommentTest.php
Tests the comment field with custom permissions.
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.
FieldPermissionsUserTest::checkUserViewEditField in tests/src/Functional/FieldPermissionsUserTest.php
Tests custom permissions.

... See full list

File

tests/src/Functional/FieldPermissionsTestBase.php, line 173

Class

FieldPermissionsTestBase
A base class for field permissions web tests to extend.

Namespace

Drupal\Tests\field_permissions\Functional

Code

protected function grantCustomPermissions($role, array $new_permissions = [], array $existing_custom_permission = []) {
  $permissions_grid = $this
    ->getCustomPermissionGrid($role, $new_permissions);
  foreach ($permissions_grid as $key => $val) {
    if (isset($existing_custom_permission[$key]) && $existing_custom_permission[$key] === TRUE) {
      $permissions_grid[$key] = TRUE;
    }
  }
  return $permissions_grid;
}