function UserRolesAccessPolicyTest::calculatePermissionsProvider

Same name in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Session/UserRolesAccessPolicyTest.php \Drupal\Tests\Core\Session\UserRolesAccessPolicyTest::calculatePermissionsProvider()

Data provider for testCalculatePermissions.

Return value

array A list of test scenarios.

File

core/tests/Drupal/Tests/Core/Session/UserRolesAccessPolicyTest.php, line 127

Class

UserRolesAccessPolicyTest
@coversDefaultClass \Drupal\Core\Session\UserRolesAccessPolicy @group Session

Namespace

Drupal\Tests\Core\Session

Code

public static function calculatePermissionsProvider() : array {
    $cases['no-roles'] = [
        'roles' => [],
        'expect_admin_rights' => FALSE,
    ];
    $cases['some-roles'] = [
        'roles' => [
            'role_foo' => [
                'permissions' => [
                    'foo',
                ],
                'is_admin' => FALSE,
            ],
            'role_bar' => [
                'permissions' => [
                    'bar',
                ],
                'is_admin' => FALSE,
            ],
        ],
        'expect_admin_rights' => FALSE,
    ];
    $cases['admin-role'] = [
        'roles' => [
            'role_foo' => [
                'permissions' => [
                    'foo',
                ],
                'is_admin' => FALSE,
            ],
            'role_bar' => [
                'permissions' => [
                    'bar',
                ],
                'is_admin' => TRUE,
            ],
        ],
        'expect_admin_rights' => TRUE,
    ];
    return $cases;
}

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