You are here

public function FppFileAccessTest::testFileAccessWithoutAuth in Fieldable Panels Panes (FPP) 7

Confirm that the private file access works when no auth is defined.

File

tests/fpp.file_access.test, line 38
Tests for the Fieldable Panels Panes module to ensure file access works.

Class

FppFileAccessTest
Tests for the Fieldable Panels Panes module to ensure file access works.

Code

public function testFileAccessWithoutAuth() {

  // Create a user with the admin permission.
  $this->adminUser = $this
    ->createAdminUser();
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->addPrivateImageField();

  // Create the FPP object.
  $fpp = $this
    ->createTestFppObject();

  // Get the file object.
  $file = file_load($fpp->field_fpp_image[LANGUAGE_NONE][0]['fid']);
  $this
    ->assertNotEqual($file, NULL);
  $url = file_create_url($file->uri);
  $this
    ->assertNotEqual($url, NULL);
  $this
    ->assertTrue(strpos($url, 'system/files'), 'File is stored in the private file system.');

  // Confirm the FPP page is accessible.
  $this
    ->drupalGet('admin/structure/fieldable-panels-panes/view/' . $fpp->fpid);
  $this
    ->assertResponse(200);

  // Confirm the file is accessible.
  $this
    ->drupalGet($url);
  $this
    ->assertResponse(200);
}