function EntityDisplayTest::testExtraFieldComponent
Same name in other branches
- 9 core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php \Drupal\Tests\field_ui\Kernel\EntityDisplayTest::testExtraFieldComponent()
- 8.9.x core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php \Drupal\Tests\field_ui\Kernel\EntityDisplayTest::testExtraFieldComponent()
- 10 core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php \Drupal\Tests\field_ui\Kernel\EntityDisplayTest::testExtraFieldComponent()
Tests the behavior of a field component within an entity display object.
File
-
core/
modules/ field_ui/ tests/ src/ Kernel/ EntityDisplayTest.php, line 176
Class
- EntityDisplayTest
- Tests the entity display configuration entities.
Namespace
Drupal\Tests\field_ui\KernelCode
public function testExtraFieldComponent() : void {
entity_test_create_bundle('bundle_with_extra_fields');
$display = EntityViewDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'bundle_with_extra_fields',
'mode' => 'default',
]);
// Check that the default visibility taken into account for extra fields
// unknown in the display.
$this->assertEquals([
'weight' => 5,
'region' => 'content',
'settings' => [],
'third_party_settings' => [],
], $display->getComponent('display_extra_field'));
$this->assertNull($display->getComponent('display_extra_field_hidden'));
// Check that setting explicit options overrides the defaults.
$display->removeComponent('display_extra_field');
$display->setComponent('display_extra_field_hidden', [
'weight' => 10,
]);
$this->assertNull($display->getComponent('display_extra_field'));
$this->assertEquals([
'weight' => 10,
'settings' => [],
'third_party_settings' => [],
], $display->getComponent('display_extra_field_hidden'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.