You are here

public function PDFToImageFilefieldPathsTest::changeFileFieldPath in PDF to ImageField 7.3

Use the UI to set the filefield path to a new token pattern.

1 call to PDFToImageFilefieldPathsTest::changeFileFieldPath()
PDFToImageFilefieldPathsTest::testAttachingPdf in tests/pdf_to_image.test
Save a document with an attached PDF, check that the image was generated.

File

tests/pdf_to_image.test, line 233
Test the file attachment and process.

Class

PDFToImageFilefieldPathsTest
Test attaching a PDF using filefield_paths patterns.

Code

public function changeFileFieldPath() {

  // @see FieldUIManageFieldsTestCase
  // Go to the field edit page.
  $this
    ->drupalGet('admin/structure/types/manage/' . $this->typeName . '/fields/' . $this->imageFieldName);

  // Change the image field settings to use a new storage path.
  $edit = array(
    'instance[settings][filefield_paths_enabled]' => TRUE,
    'instance[settings][filefield_paths][file_path][value]' => 'custom',
    'instance[settings][filefield_paths][file_name][value]' => $this->customPattern,
  );
  $this
    ->drupalPost(NULL, $edit, t('Save settings'));

  // Assert the field settings are saved and correct.
  // Check settings in the UI persist.
  $this
    ->drupalGet('admin/structure/types/manage/' . $this->typeName . '/fields/' . $this->imageFieldName);

  // Also check via the back end.
  field_info_cache_clear();
  $instance = field_info_instance('node', $this->imageFieldName, $this->typeName);
  $this
    ->assertTrue($instance['settings']['filefield_paths']['file_path']['value'] == 'custom', 'Fieldfield path setting change was saved correctly.');
  $message = format_string('Fieldfield path setting uses a custom token pattern %customPattern.', array(
    '%customPattern' => $this->customPattern,
  ));
  $this
    ->assertTrue($instance['settings']['filefield_paths']['file_name']['value'] == $this->customPattern, $message);
}