You are here

public function AccessResultTest::providerTestAllowedIfHasPermissions in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Access/AccessResultTest.php \Drupal\Tests\Core\Access\AccessResultTest::providerTestAllowedIfHasPermissions()
  2. 10 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 945
Contains \Drupal\Tests\Core\Access\AccessResultTest.

Class

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

Namespace

Drupal\Tests\Core\Access

Code

public 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;
}