function UserCreationTrait::grantPermissions
Same name in other branches
- 9 core/modules/user/tests/src/Traits/UserCreationTrait.php \Drupal\Tests\user\Traits\UserCreationTrait::grantPermissions()
- 8.9.x 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.
28 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.
- ContentTranslationEnableTest::testEnable in core/
modules/ content_translation/ tests/ src/ Functional/ ContentTranslationEnableTest.php - Tests that entity schemas are up-to-date after enabling translation.
- 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.
File
-
core/
modules/ user/ tests/ src/ Traits/ UserCreationTrait.php, line 313
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.