You are here

function FileFieldTestBase::replaceNodeFile in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/file/src/Tests/FileFieldTestBase.php \Drupal\file\Tests\FileFieldTestBase::replaceNodeFile()

Replaces a file within a node.

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

File

core/modules/file/src/Tests/FileFieldTestBase.php, line 252
Contains \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 . '_0]' => drupal_realpath($file
      ->getFileUri()),
    'revision' => (string) (int) $new_revision,
  );
  $this
    ->drupalPostForm('node/' . $nid . '/edit', array(), t('Remove'));
  $this
    ->drupalPostForm(NULL, $edit, t('Save and keep published'));
}