function AccessResultTest::providerTestAllowedIfHasPermissions

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Access/AccessResultTest.php \Drupal\Tests\Core\Access\AccessResultTest::providerTestAllowedIfHasPermissions()
  2. 8.9.x core/tests/Drupal/Tests/Core/Access/AccessResultTest.php \Drupal\Tests\Core\Access\AccessResultTest::providerTestAllowedIfHasPermissions()
  3. 11.x core/tests/Drupal/Tests/Core/Access/AccessResultTest.php \Drupal\Tests\Core\Access\AccessResultTest::providerTestAllowedIfHasPermissions()

Provides data for the testAllowedIfHasPermissions() method.

Return value

array

File

core/tests/Drupal/Tests/Core/Access/AccessResultTest.php, line 943

Class

AccessResultTest
@coversDefaultClass \Drupal\Core\Access\AccessResult @group Access

Namespace

Drupal\Tests\Core\Access

Code

public static function providerTestAllowedIfHasPermissions() {
    $access_result = AccessResult::allowedIf(FALSE);
    $data[] = [
        [],
        'AND',
        $access_result,
    ];
    $data[] = [
        [],
        'OR',
        $access_result,
    ];
    $access_result = AccessResult::allowedIf(TRUE);
    $data[] = [
        [
            'allowed',
        ],
        'OR',
        $access_result,
    ];
    $data[] = [
        [
            'allowed',
        ],
        'AND',
        $access_result,
    ];
    $access_result = AccessResult::allowedIf(FALSE);
    $access_result->setReason("The 'denied' permission is required.");
    $data[] = [
        [
            'denied',
        ],
        'OR',
        $access_result,
    ];
    $data[] = [
        [
            'denied',
        ],
        'AND',
        $access_result,
    ];
    $access_result = AccessResult::allowedIf(TRUE);
    $data[] = [
        [
            'allowed',
            'denied',
        ],
        'OR',
        $access_result,
    ];
    $data[] = [
        [
            'denied',
            'allowed',
        ],
        'OR',
        $access_result,
    ];
    $access_result = AccessResult::allowedIf(TRUE);
    $data[] = [
        [
            'allowed',
            'denied',
            'other',
        ],
        'OR',
        $access_result,
    ];
    $access_result = AccessResult::allowedIf(FALSE);
    $access_result->setReason("The following permissions are required: 'allowed' AND 'denied'.");
    $data[] = [
        [
            'allowed',
            'denied',
        ],
        'AND',
        $access_result,
    ];
    return $data;
}

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