PermissionsTest.php

Same filename in other branches
  1. 9 core/modules/system/tests/src/Kernel/PermissionsTest.php
  2. 10 core/modules/system/tests/src/Kernel/PermissionsTest.php
  3. 10 core/modules/user/tests/src/Unit/Plugin/views/field/PermissionsTest.php
  4. 11.x core/modules/system/tests/src/Kernel/PermissionsTest.php
  5. 11.x core/modules/user/tests/src/Unit/Plugin/views/field/PermissionsTest.php

Namespace

Drupal\Tests\system\Kernel

File

core/modules/system/tests/src/Kernel/PermissionsTest.php

View source
<?php

namespace Drupal\Tests\system\Kernel;

use Drupal\KernelTests\KernelTestBase;

/**
 * @group system
 */
class PermissionsTest extends KernelTestBase {
    
    /**
     * {@inheritdoc}
     */
    public static $modules = [
        'system',
        'user',
    ];
    
    /**
     * Tests the 'access content' permission is provided by the System module.
     */
    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']);
    }

}

Classes

Title Deprecated Summary
PermissionsTest @group system

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.