You are here

function FileFieldPathsTestCase::uploadNodeFile in File (Field) Paths 6

Same name and namespace in other branches
  1. 6.2 tests/filefield_paths.test \FileFieldPathsTestCase::uploadNodeFile()

Upload a file to a node.

Modified version of FileFieldTestCase::uploadNodeFile().

2 calls to FileFieldPathsTestCase::uploadNodeFile()
FileFieldPathsUploadTestCase::testUploadFile in tests/filefield_paths.test
Test file upload.
filefield_paths.test in tests/filefield_paths.test
This file implements tests for FileField Paths.

File

tests/filefield_paths.test, line 40
This file implements tests for FileField Paths.

Class

FileFieldPathsTestCase
@file This file implements tests for FileField Paths.

Code

function uploadNodeFile($file, $field_name, $type) {
  $edit = array(
    'title' => $this
      ->randomName(),
    'files[' . $field_name . ']' => realpath($file['path']),
    'body' => l(t('link'), file_directory_path() . '/' . $file['name']),
  );
  $type = str_replace('_', '-', $type);
  $this
    ->drupalPost('node/add/' . $type, $edit, t('Save'));
  $matches = array();
  preg_match('/node\\/([0-9]+)/', $this
    ->getUrl(), $matches);
  return isset($matches[1]) ? $matches[1] : FALSE;
}