function EntityDisplayDependenciesTest::testDisplaysWithMultipleDependencies

Tests that entity display dependencies are calculated from multiple fields.

File

core/modules/field_ui/tests/src/Kernel/EntityDisplayDependenciesTest.php, line 47

Class

EntityDisplayDependenciesTest
Tests dependencies of entity displays.

Namespace

Drupal\Tests\field_ui\Kernel

Code

public function testDisplaysWithMultipleDependencies() : void {
  // Set up two field components, each dependent on different arbitrary
  // modules that should not already be dependencies otherwise.
  $dependent_fields = [
    'test_field' => 'action',
    'test_field_2' => 'aggregator',
  ];
  $this->addDefaultTestFields(array_keys($dependent_fields));
  // Now that the fields exist, set up the display.
  $display = EntityViewDisplay::create([
    'targetEntityType' => 'entity_test',
    'bundle' => 'entity_test',
    'mode' => 'default',
  ]);
  $this->addFieldsToDisplay($dependent_fields, $display);
  $this->assertDisplayDependencies($dependent_fields, $display);
  $form_display = EntityFormDisplay::create([
    'targetEntityType' => 'entity_test',
    'bundle' => 'entity_test',
    'mode' => 'default',
  ]);
  $this->addFieldsToDisplay($dependent_fields, $form_display);
  $this->assertDisplayDependencies($dependent_fields, $form_display);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.