You are here

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

Create a test FPP object that contains a generated image.

Return value

object An FPP object.

3 calls to FppFileAccessTest::createTestFppObject()
FppFileAccessTest::testFileAccessWithCorrectAuth in tests/fpp.file_access.test
Confirm private file access works when the visitor DOES have access.
FppFileAccessTest::testFileAccessWithIncorrectAuth in tests/fpp.file_access.test
Confirm private file access works when the visitor does NOT have access.
FppFileAccessTest::testFileAccessWithoutAuth in tests/fpp.file_access.test
Confirm that the private file access works when no auth is defined.

File

tests/fpp.file_access.test, line 181
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 createTestFppObject() {

  // Generate a suitable private image file.
  $image = $this
    ->generateImageFile(NULL, NULL, 'private');
  $fpp = new StdClass();
  $fpp->bundle = $this->bundle;
  $fpp->title = $this->title;
  $fpp->field_fpp_image[LANGUAGE_NONE][0]['fid'] = $image->fid;
  $saved_fpp = fieldable_panels_panes_save($fpp);

  // Force a reload of this object, just to be sure.
  $saved_fpp = fieldable_panels_panes_load($saved_fpp->fpid);
  $this
    ->assertEqual($saved_fpp->title, $this->title, 'The FPP object was saved.');
  $this
    ->assertEqual($saved_fpp->field_fpp_image[LANGUAGE_NONE][0]['fid'], $image->fid, 'The FPP object contains the image.');
  $this
    ->drupalGet('admin/structure/fieldable-panels-panes/' . $this->bundle);
  $this
    ->assertResponse(200);
  $this
    ->assertText($this->title);
  return $saved_fpp;
}