You are here

public function RestPermissionsTest::testPermissions in Drupal 10

Same name and namespace in other branches
  1. 9 core/modules/rest/tests/src/Kernel/Entity/RestPermissionsTest.php \Drupal\Tests\rest\Kernel\Entity\RestPermissionsTest::testPermissions()

@covers ::permissions

File

core/modules/rest/tests/src/Kernel/Entity/RestPermissionsTest.php, line 30

Class

RestPermissionsTest
@coversDefaultClass \Drupal\rest\RestPermissions

Namespace

Drupal\Tests\rest\Kernel\Entity

Code

public function testPermissions() {
  RestResourceConfig::create([
    'id' => 'dblog',
    'plugin_id' => 'dblog',
    'granularity' => RestResourceConfigInterface::METHOD_GRANULARITY,
    'configuration' => [
      'GET' => [
        'supported_auth' => [
          'cookie',
        ],
        'supported_formats' => [
          'json',
        ],
      ],
    ],
  ])
    ->save();
  $permissions = $this->container
    ->get('user.permissions')
    ->getPermissions();
  $this
    ->assertArrayHasKey('restful get dblog', $permissions);
  $this
    ->assertSame([
    'config' => [
      'rest.resource.dblog',
    ],
  ], $permissions['restful get dblog']['dependencies']);
}