You are here

public function PermissionsTest::testAccessContentPermission in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Kernel/PermissionsTest.php \Drupal\Tests\system\Kernel\PermissionsTest::testAccessContentPermission()
  2. 10 core/modules/system/tests/src/Kernel/PermissionsTest.php \Drupal\Tests\system\Kernel\PermissionsTest::testAccessContentPermission()

Tests the 'access content' permission is provided by the System module.

File

core/modules/system/tests/src/Kernel/PermissionsTest.php, line 23

Class

PermissionsTest
@group system

Namespace

Drupal\Tests\system\Kernel

Code

public function testAccessContentPermission() {

  // 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']);
}