function FileFieldTestCase::replaceNodeFile in Drupal 7
Replaces a file within a node.
1 call to FileFieldTestCase::replaceNodeFile()
- FileFieldRevisionTestCase::testRevisions in modules/
file/ tests/ file.test - Tests creating multiple revisions of a node and managing attached files.
File
- modules/
file/ tests/ file.test, line 169 - Tests for file.module.
Class
- FileFieldTestCase
- 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]' => drupal_realpath($file->uri),
'revision' => (string) (int) $new_revision,
);
$this
->drupalPost('node/' . $nid . '/edit', array(), t('Remove'));
$this
->drupalPost(NULL, $edit, t('Save'));
}