1 file.test | FileTestHelper::replaceNodeFile($file, $field_name, $nid, $new_revision = TRUE) |
Replaces a file within a node.
Parameters
string $field_name: Name of the field.
int $nid: Node ID.
bool $new_revision: If TRUE, create a new revision.
File
- core/
modules/ file/ tests/ file.test, line 349 - 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'));
}