Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291693

Change "$role" parameter to "$roleId" in "grantPermissions()"

$
0
0

Problem/Motivation

Currently, the "Drupal\Tests\user\Traits\UserCreationTrait::grantPermissions" method, requires two parameters a RoleInterface object and an array with permission IDs. This isn't optimal, since we can't easily get the Role object of a specific role inside our tests.

The reason behind this is, that if we create roles inside our Tests, we usually do this via "UserCreationTrait::createAdminRole()" or "UserCreationTrait::createRole()". Both of these methods only return the role ID of the newly created role. So Instead of just passing the role ID to "grantPermissions", we first need to load the Role object via the role ID and then pass the Role object to the function, which is not very intuitive.

Steps to reproduce

Proposed resolution

Change the first parameter of "UserCreationTrait::grantPermissions" from "\Drupal\user\RoleInterface $role" to "string $roleId" and adjust the method implementation accordingly.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 291693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>