function UserCreationTrait::grantPermissions
Same name in other branches
- 8.9.x core/modules/user/tests/src/Traits/UserCreationTrait.php \Drupal\Tests\user\Traits\UserCreationTrait::grantPermissions()
- 10 core/modules/user/tests/src/Traits/UserCreationTrait.php \Drupal\Tests\user\Traits\UserCreationTrait::grantPermissions()
- 11.x core/modules/user/tests/src/Traits/UserCreationTrait.php \Drupal\Tests\user\Traits\UserCreationTrait::grantPermissions()
Grant permissions to a user role.
Parameters
\Drupal\user\RoleInterface $role: The user role entity to alter.
array $permissions: (optional) A list of permission names to grant.
27 calls to UserCreationTrait::grantPermissions()
- BasicAuthTest::testCacheabilityOf401Response in core/
modules/ basic_auth/ tests/ src/ Functional/ BasicAuthTest.php - Tests the cacheability of the Basic Auth 401 response.
- ConfigAccessTest::testBlockConfigAccess in core/
modules/ settings_tray/ tests/ src/ FunctionalJavascript/ ConfigAccessTest.php - Tests access to block forms with related configuration is correct.
- ContextualLinksTest::testContextualLinksClick in core/
modules/ contextual/ tests/ src/ FunctionalJavascript/ ContextualLinksTest.php - Tests clicking contextual links.
- ContextualLinksTest::testContextualLinksDestination in core/
modules/ contextual/ tests/ src/ FunctionalJavascript/ ContextualLinksTest.php - Tests the contextual links destination.
- ContextualLinksTest::testContextualLinksDestinationWithQuery in core/
modules/ contextual/ tests/ src/ FunctionalJavascript/ ContextualLinksTest.php - Tests the contextual links destination with query.
File
-
core/
modules/ user/ tests/ src/ Traits/ UserCreationTrait.php, line 320
Class
- UserCreationTrait
- Provides test methods for user creation and authentication.
Namespace
Drupal\Tests\user\TraitsCode
protected function grantPermissions(RoleInterface $role, array $permissions) {
foreach ($permissions as $permission) {
$role->grantPermission($permission);
}
$role->trustData()
->save();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.