diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php
index 6788209705..c6c4ff5ce7 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php
@@ -2,6 +2,8 @@
 
 namespace Drupal\KernelTests\Core\Entity;
 
+use Drupal\Core\Entity\EntityManagerInterface;
+use Drupal\Core\Entity\EntityTypeInterface;
 use Drupal\Core\Entity\TypedData\EntityDataDefinition;
 use Drupal\Core\Entity\TypedData\EntityDataDefinitionInterface;
 use Drupal\Core\Field\BaseFieldDefinition;
@@ -138,4 +140,36 @@ public function testEntityReferences() {
     $this->assertEqual(serialize($reference_definition2), serialize($reference_definition));
   }
 
+  /**
+   * Tests that an entity annotation can mark the data definition as internal.
+   *
+   * @dataProvider entityDefinitionIsInternalProvider
+   */
+  public function testEntityDefinitionIsInternal($internal, $expected) {
+    $entity_type_id = $this->randomMachineName();
+
+    $entity_type = $this->prophesize(EntityTypeInterface::class);
+    $entity_type->getLabel()->willReturn($this->randomString());
+    $entity_type->getConstraints()->willReturn([]);
+    $entity_type->isInternal()->willReturn($internal);
+
+    $entity_manager = $this->prophesize(EntityManagerInterface::class);
+    $entity_manager->getDefinitions()->willReturn([$entity_type_id => $entity_type->reveal()]);
+    $this->container->set('entity.manager', $entity_manager->reveal());
+
+    $entity_data_definition = EntityDataDefinition::create($entity_type_id);
+    $this->assertSame($expected, $entity_data_definition->isInternal());
+  }
+
+  /**
+   * Provides cases for testEntityDefinitionIsInternal.
+   */
+  public function entityDefinitionIsInternalProvider() {
+    return [
+      'internal' => [TRUE, TRUE],
+      'external' => [FALSE, FALSE],
+      'undefined' => [NULL, FALSE],
+    ];
+  }
+
 }
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php
index 5c97afad6d..b28a72c617 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php
@@ -127,6 +127,18 @@ public function providerTestGetKeys() {
     ];
   }
 
+  /**
+   * Tests the isInternal() method.
+   */
+  public function testIsInternal() {
+    $entity_type = $this->setUpEntityType(['internal' => TRUE]);
+    $this->assertTrue($entity_type->isInternal());
+    $entity_type = $this->setUpEntityType(['internal' => FALSE]);
+    $this->assertFalse($entity_type->isInternal());
+    $entity_type = $this->setUpEntityType([]);
+    $this->assertFalse($entity_type->isInternal());
+  }
+
   /**
    * Tests the isRevisionable() method.
    */
