You are here

public function FileFieldTestBase::updateFileField in Drupal 8

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

Updates an existing file field with new settings.

6 calls to FileFieldTestBase::updateFileField()
FileFieldPathTest::testUploadPath in core/modules/file/tests/src/Functional/FileFieldPathTest.php
Tests the normal formatter display on node display.
FileFieldValidateTest::testAssertFileExistsDeprecation in core/modules/file/tests/src/Functional/FileFieldValidateTest.php
Tests deprecation of the assertFileExists and assertFileNotExists methods.
FileFieldValidateTest::testFileExtension in core/modules/file/tests/src/Functional/FileFieldValidateTest.php
Tests file extension checking.
FileFieldValidateTest::testFileMaxSize in core/modules/file/tests/src/Functional/FileFieldValidateTest.php
Tests the max file size validator.
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.

... See full list

File

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

Class

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

Namespace

Drupal\Tests\file\Functional

Code

public function updateFileField($name, $type_name, $field_settings = [], $widget_settings = []) {
  $field = FieldConfig::loadByName('node', $type_name, $name);
  $field
    ->setSettings(array_merge($field
    ->getSettings(), $field_settings));
  $field
    ->save();
  \Drupal::service('entity_display.repository')
    ->getFormDisplay('node', $type_name)
    ->setComponent($name, [
    'settings' => $widget_settings,
  ])
    ->save();
}