function FileFieldTestBase::replaceNodeFile

Replaces a file within a node.

1 call to FileFieldTestBase::replaceNodeFile()
FileFieldRevisionTest::testRevisions in drupal/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php
Tests creating multiple revisions of a node and managing attached files.

File

drupal/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php, line 188
Definition of Drupal\file\Tests\FileFieldTestBase.

Class

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

Namespace

Drupal\file\Tests

Code

function replaceNodeFile($file, $field_name, $nid, $new_revision = TRUE) {
  $edit = array(
    'files[' . $field_name . '_' . Language::LANGCODE_NOT_SPECIFIED . '_0]' => drupal_realpath($file->uri),
    'revision' => (string) (int) $new_revision,
  );
  $this
    ->drupalPost('node/' . $nid . '/edit', array(), t('Remove'));
  $this
    ->drupalPost(NULL, $edit, t('Save and keep published'));
}