You are here

protected function FileEntityTestBase::getPrivateDownloadAccessCases in File Entity (fieldable files) 8.2

Helper for testFileEntityPrivateDownloadAccess() test.

Defines several cases for accesing private files.

Return value

array Array of associative arrays, each one having the next keys:

  • "message" string with the assertion message.
  • "permissions" array of permissions or NULL for anonymous user.
  • "expect" expected HTTP response code.
  • "owner" Optional boolean indicating if the user is a file owner.
1 call to FileEntityTestBase::getPrivateDownloadAccessCases()
FileEntityAccessTest::testFileEntityPrivateDownloadAccess in tests/src/Functional/FileEntityAccessTest.php
Test to see if we have access to download private files when granted the permissions.

File

tests/src/Functional/FileEntityTestBase.php, line 104

Class

FileEntityTestBase
Base class for file entity tests.

Namespace

Drupal\Tests\file_entity\Functional

Code

protected function getPrivateDownloadAccessCases() {
  return array(
    array(
      'message' => "File owners cannot download their own files unless they are granted the 'view own private files' permission.",
      'permissions' => array(),
      'expect' => 403,
      'owner' => TRUE,
    ),
    array(
      'message' => "File owners can download their own files as they have been granted the 'view own private files' permission.",
      'permissions' => array(
        'view own private files',
      ),
      'expect' => 200,
      'owner' => TRUE,
    ),
    array(
      'message' => "Anonymous users cannot download private files.",
      'permissions' => NULL,
      'expect' => 403,
    ),
    array(
      'message' => "Authenticated users cannot download each other's private files.",
      'permissions' => array(),
      'expect' => 403,
    ),
    array(
      'message' => "Users who can view public files are not able to download private files.",
      'permissions' => array(
        'view files',
      ),
      'expect' => 403,
    ),
    array(
      'message' => "Users who bypass file access can download any file.",
      'permissions' => array(
        'bypass file access',
      ),
      'expect' => 200,
    ),
  );
}