public function FileFieldTestBase::replaceNodeFile in Drupal 10
Same name and namespace in other branches
- 8 core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::replaceNodeFile()
- 9 core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::replaceNodeFile()
Replaces a file within a node.
File
- core/
modules/ file/ tests/ src/ Functional/ FileFieldTestBase.php, line 208
Class
- FileFieldTestBase
- Provides methods specifically for testing File module's field handling.
Namespace
Drupal\Tests\file\FunctionalCode
public function replaceNodeFile($file, $field_name, $nid, $new_revision = TRUE) {
$edit = [
'files[' . $field_name . '_0]' => \Drupal::service('file_system')
->realpath($file
->getFileUri()),
'revision' => (string) (int) $new_revision,
];
$this
->drupalGet('node/' . $nid . '/edit');
$this
->submitForm([], 'Remove');
$this
->submitForm($edit, 'Save');
}