1 file.test FileAccessTestCase::getPrivateDownloadAccessCases()

Helper for testFilePrivateDownloadAccess() test.

Defines several cases for accessing 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.

File

core/modules/file/tests/file.test, line 3618
Tests for file.module.

Class

FileAccessTestCase
Tests the file entity access API.

Code

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,
    ),
  );
}