You are here

protected function PDFToImageFilefieldPathsTest::uploadNodeFile in PDF to ImageField 7.3

Uploads a file to a node.

See also

file.test

1 call to PDFToImageFilefieldPathsTest::uploadNodeFile()
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 321
Test the file attachment and process.

Class

PDFToImageFilefieldPathsTest
Test attaching a PDF using filefield_paths patterns.

Code

protected function uploadNodeFile($file, $field_name, $type, $new_revision = TRUE, $extras = array()) {
  $langcode = LANGUAGE_NONE;
  $edit = array(
    "title" => $this
      ->randomName(),
    'revision' => (string) (int) $new_revision,
  );

  // Add a new node.
  $extras['type'] = $type;
  $node = $this
    ->drupalCreateNode($extras);
  $nid = $node->nid;

  // Attach a file to the node.
  $edit['files[' . $field_name . '_' . $langcode . '_0]'] = drupal_realpath($file->uri);
  $this
    ->drupalPost("node/{$nid}/edit", $edit, t('Save'));
  return $nid;
}