function EntityFormDisplayTest::testSerialization
Same name in other branches
- 10 core/modules/field_ui/tests/src/Kernel/EntityFormDisplayTest.php \Drupal\Tests\field_ui\Kernel\EntityFormDisplayTest::testSerialization()
Tests the serialization and unserialization of the class.
File
-
core/
modules/ field_ui/ tests/ src/ Kernel/ EntityFormDisplayTest.php, line 295
Class
- EntityFormDisplayTest
- Tests the entity display configuration entities.
Namespace
Drupal\Tests\field_ui\KernelCode
public function testSerialization() : void {
/** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */
$display_repository = \Drupal::service('entity_display.repository');
$form_display = $display_repository->getFormDisplay('entity_test', 'entity_test');
// Make sure the langcode base field is visible in the original form
// display.
$this->assertNotEmpty($form_display->getComponent('langcode'));
// Remove the langcode.
$form_display->removeComponent('langcode');
$unserialized = unserialize(serialize($form_display));
// Verify that components are retained upon unserialization.
$this->assertEquals($form_display->getComponents(), $unserialized->getComponents());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.