public function EntityDisplayTest::testExtraFieldComponentInitialInvalidConfig in Drupal 10
Same name and namespace in other branches
- 8 core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php \Drupal\Tests\field_ui\Kernel\EntityDisplayTest::testExtraFieldComponentInitialInvalidConfig()
- 9 core/modules/field_ui/tests/src/Kernel/EntityDisplayTest.php \Drupal\Tests\field_ui\Kernel\EntityDisplayTest::testExtraFieldComponentInitialInvalidConfig()
Tests the behavior of an extra field component with initial invalid values.
File
- core/modules/ field_ui/ tests/ src/ Kernel/ EntityDisplayTest.php, line 193 
Class
- EntityDisplayTest
- Tests the entity display configuration entities.
Namespace
Drupal\Tests\field_ui\KernelCode
public function testExtraFieldComponentInitialInvalidConfig() {
  entity_test_create_bundle('bundle_with_extra_fields');
  $display = EntityViewDisplay::create([
    'targetEntityType' => 'entity_test',
    'bundle' => 'bundle_with_extra_fields',
    'mode' => 'default',
    // Add the extra field to the initial config, without a 'type'.
    'content' => [
      'display_extra_field' => [
        'weight' => 5,
      ],
    ],
  ]);
  // Check that the default visibility taken into account for extra fields
  // unknown in the display that were included in the initial config.
  $this
    ->assertEquals([
    'weight' => 5,
    'region' => 'content',
  ], $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'));
}