Skip to content

Commit

Permalink
Fix for deprecation user_role_permissions() (#985)
Browse files Browse the repository at this point in the history
  • Loading branch information
divya-intelli authored Nov 21, 2023
1 parent 30a4a5a commit 9c6889e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/src/Functional/DeveloperAppPermissionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Apigee\Edge\Api\Management\Entity\App;
use Drupal\apigee_edge\Entity\Developer;
use Drupal\apigee_edge\Entity\DeveloperApp;
use Drupal\user\Entity\Role;
use Drupal\user\RoleInterface;

/**
Expand Down Expand Up @@ -203,9 +204,13 @@ public function testPermissions() {
*/
protected function revokeDefaultAuthUserPermissions() {
$definition = $this->entityType;
// @todo user_role_permissions() is deprecated for Drupal 10.1 https://www.drupal.org/node/3348138
// @phpstan-ignore-next-line
$user_permissions = user_role_permissions([RoleInterface::AUTHENTICATED_ID]);
$roles = [RoleInterface::AUTHENTICATED_ID];
$entities = Role::loadMultiple($roles);

$user_permissions = [];
foreach ($roles as $rid) {
$user_permissions[$rid] = $entities[$rid]->getPermissions() ?: [];
}
$authenticated_user_permissions = array_filter($user_permissions[RoleInterface::AUTHENTICATED_ID], function ($perm) use ($definition) {
return preg_match("/own {$definition->id()}$/", $perm);
});
Expand Down

0 comments on commit 9c6889e

Please sign in to comment.