You are here

protected function FieldDefinitionIntegrityTest::checkDisplayOption in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php \Drupal\Tests\field\Kernel\FieldDefinitionIntegrityTest::checkDisplayOption()
  2. 9 core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php \Drupal\Tests\field\Kernel\FieldDefinitionIntegrityTest::checkDisplayOption()

Helper method that tries to load plugin definitions.

Parameters

string $entity_type_id: Id of entity type. Required by message.

string $field_id: Id of field. Required by message.

\Drupal\Core\Field\BaseFieldDefinition $field_definition: Field definition that provide display options.

\Drupal\Component\Plugin\Discovery\DiscoveryInterface $plugin_manager: Plugin manager that will try to provide plugin definition.

string $display_context: Defines which display options should be loaded.

File

core/modules/field/tests/src/Kernel/FieldDefinitionIntegrityTest.php, line 144

Class

FieldDefinitionIntegrityTest
Tests the integrity of field API plugin definitions.

Namespace

Drupal\Tests\field\Kernel

Code

protected function checkDisplayOption($entity_type_id, $field_id, BaseFieldDefinition $field_definition, DiscoveryInterface $plugin_manager, $display_context) {
  $display_options = $field_definition
    ->getDisplayOptions($display_context);
  if (!empty($display_options['type'])) {
    $plugin = $plugin_manager
      ->getDefinition($display_options['type'], FALSE);
    $this
      ->assertNotNull($plugin, sprintf('Plugin found for "%s" field %s display options of "%s" entity type.', $field_id, $display_context, $entity_type_id));
  }
}