summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/system/tests/src/Kernel/PermissionsTest.php
blob: 5f03065ecabf456a6be1e883f2067e35a7b7aedc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php

declare(strict_types=1);

namespace Drupal\Tests\system\Kernel;

use Drupal\KernelTests\KernelTestBase;

/**
 * @group system
 */
class PermissionsTest extends KernelTestBase {

  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'system',
    'user',
  ];

  /**
   * Tests the 'access content' permission is provided by the System module.
   */
  public function testAccessContentPermission(): void {
    // Uninstalling modules requires the users_data table to exist.
    $this->installSchema('user', ['users_data']);

    $permissions = $this->container->get('user.permissions')->getPermissions();
    $this->assertSame('system', $permissions['access content']['provider']);

    // Install the 'node' module, assert that it is now the 'node' module
    // providing the 'access content' permission.
    $this->container->get('module_installer')->install(['node']);

    $permissions = $this->container->get('user.permissions')->getPermissions();
    $this->assertSame('system', $permissions['access content']['provider']);

    // Uninstall the 'node' module, assert that it is again the 'system' module.
    $this->container->get('module_installer')->uninstall(['node']);

    $permissions = $this->container->get('user.permissions')->getPermissions();
    $this->assertSame('system', $permissions['access content']['provider']);
  }

}