function FieldSettingsTest::testBaseFieldSettingsOnClone
Same name in other branches
- 8.9.x core/tests/Drupal/KernelTests/Core/Field/FieldSettingsTest.php \Drupal\KernelTests\Core\Field\FieldSettingsTest::testBaseFieldSettingsOnClone()
- 10 core/tests/Drupal/KernelTests/Core/Field/FieldSettingsTest.php \Drupal\KernelTests\Core\Field\FieldSettingsTest::testBaseFieldSettingsOnClone()
- 11.x core/tests/Drupal/KernelTests/Core/Field/FieldSettingsTest.php \Drupal\KernelTests\Core\Field\FieldSettingsTest::testBaseFieldSettingsOnClone()
Tests the base field settings on a cloned base field definition object.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Field/ FieldSettingsTest.php, line 52
Class
- FieldSettingsTest
- Tests field settings methods on field definition structures.
Namespace
Drupal\KernelTests\Core\FieldCode
public function testBaseFieldSettingsOnClone() {
$base_field = BaseFieldDefinition::create('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',
'test_field_setting' => 'dummy test string',
'translatable_field_setting' => 'a translatable field setting',
];
$this->assertEquals($expected_settings, $base_field->getSettings());
// Clone the base field object and change one single setting using
// setSettings() on the cloned base field and check that it has been
// changed only on the cloned object.
$clone_base_field = clone $base_field;
$expected_settings_clone = $expected_settings;
$expected_settings_clone['changeable'] = $expected_settings['changeable'] . ' (clone)';
$clone_base_field->setSetting('changeable', $expected_settings_clone['changeable']);
$this->assertEquals($expected_settings, $base_field->getSettings());
$this->assertEquals($expected_settings_clone, $clone_base_field->getSettings());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.