You are here

public function FieldSettingsTest::testConfigurableFieldStorageSettings in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Field/FieldSettingsTest.php \Drupal\KernelTests\Core\Field\FieldSettingsTest::testConfigurableFieldStorageSettings()
  2. 9 core/tests/Drupal/KernelTests/Core/Field/FieldSettingsTest.php \Drupal\KernelTests\Core\Field\FieldSettingsTest::testConfigurableFieldStorageSettings()

@covers \Drupal\field\Entity\FieldStorageConfig::getSettings @covers \Drupal\field\Entity\FieldStorageConfig::setSettings

File

core/tests/Drupal/KernelTests/Core/Field/FieldSettingsTest.php, line 81

Class

FieldSettingsTest
Tests field settings methods on field definition structures.

Namespace

Drupal\KernelTests\Core\Field

Code

public function testConfigurableFieldStorageSettings() {
  $field_storage = FieldStorageConfig::create([
    'field_name' => 'test_field',
    'entity_type' => 'entity_test',
    'type' => 'test_field',
  ]);

  // Check that the default settings have been populated.
  $expected_settings = [
    'test_field_storage_setting' => 'dummy test string',
    'changeable' => 'a changeable field storage setting',
    'unchangeable' => 'an unchangeable field storage setting',
    'translatable_storage_setting' => 'a translatable field storage setting',
  ];
  $this
    ->assertEquals($expected_settings, $field_storage
    ->getSettings());

  // Change one single setting using setSettings(), and check that the other
  // expected settings are still present.
  $expected_settings['test_field_storage_setting'] = 'another test string';
  $field_storage
    ->setSettings([
    'test_field_storage_setting' => $expected_settings['test_field_storage_setting'],
  ]);
  $this
    ->assertEquals($expected_settings, $field_storage
    ->getSettings());
}