1.20.x file.test FileTestHelper::replaceNodeFile($file, $field_name, $nid, $new_revision = TRUE)

Replaces a file within a node.

File

modules/file/tests/file.test, line 281
Tests for file.module.

Class

FileTestHelper
Provides methods specifically for testing File module's field handling.

Code

function replaceNodeFile($file, $field_name, $nid, $new_revision = TRUE) {
  $edit = array(
    'files[' . $field_name . '_' . LANGUAGE_NONE . '_0]' => backdrop_realpath($file->uri),
    'revision' => (string) (int) $new_revision,
  );

  $this->backdropPost('node/' . $nid . '/edit', array(), t('Remove'));
  $this->backdropPost(NULL, $edit, t('Save'));
}