protected function UserCreationTrait::grantPermissions in Drupal 9
Same name and namespace in other branches
- 8 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.
25 calls to UserCreationTrait::grantPermissions()
- BasicAuthTest::testCacheabilityOf401Response in core/
modules/ basic_auth/ tests/ src/ Functional/ BasicAuthTest.php - Tests the cacheability of Basic Auth's 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::testContextualLinksVisibility in core/
modules/ contextual/ tests/ src/ FunctionalJavascript/ ContextualLinksTest.php - Tests the visibility of contextual links.
File
- core/
modules/ user/ tests/ src/ Traits/ UserCreationTrait.php, line 321
Class
- UserCreationTrait
- Provides methods to create additional test users and switch the currently logged in one.
Namespace
Drupal\Tests\user\TraitsCode
protected function grantPermissions(RoleInterface $role, array $permissions) {
foreach ($permissions as $permission) {
$role
->grantPermission($permission);
}
$role
->trustData()
->save();
}