You are here

public function FileFieldTestBase::removeNodeFile in Drupal 8

Same name in this branch
  1. 8 core/modules/file/src/Tests/FileFieldTestBase.php \Drupal\file\Tests\FileFieldTestBase::removeNodeFile()
  2. 8 core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::removeNodeFile()
Same name and namespace in other branches
  1. 9 core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::removeNodeFile()
  2. 10 core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::removeNodeFile()

Removes a file from a node.

Note that if replacing a file, it must first be removed then added again.

1 call to FileFieldTestBase::removeNodeFile()
FileFieldValidateTest::testFileRemoval in core/modules/file/tests/src/Functional/FileFieldValidateTest.php
Checks that a file can always be removed if it does not pass validation.

File

core/modules/file/tests/src/Functional/FileFieldTestBase.php, line 201

Class

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

Namespace

Drupal\Tests\file\Functional

Code

public function removeNodeFile($nid, $new_revision = TRUE) {
  $edit = [
    'revision' => (string) (int) $new_revision,
  ];
  $this
    ->drupalPostForm('node/' . $nid . '/edit', [], t('Remove'));
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));
}