You are here

public function EntityFieldTest::testDataTypes in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php \Drupal\KernelTests\Core\Entity\EntityFieldTest::testDataTypes()
  2. 10 core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php \Drupal\KernelTests\Core\Entity\EntityFieldTest::testDataTypes()

Makes sure data types are correctly derived for all entity types.

File

core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php, line 620

Class

EntityFieldTest
Tests the Entity Field API.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testDataTypes() {
  $types = \Drupal::typedDataManager()
    ->getDefinitions();
  foreach (entity_test_entity_types() as $entity_type) {
    $this
      ->assertNotEmpty($types['entity:' . $entity_type]['class'], 'Entity data type registered.');
  }

  // Check bundle types are provided as well.
  entity_test_create_bundle('bundle');
  $types = \Drupal::typedDataManager()
    ->getDefinitions();
  $this
    ->assertNotEmpty($types['entity:entity_test:bundle']['class'], 'Entity bundle data type registered.');
}