function EntityTypedDataDefinitionTest::testEntityDefinitionIsInternal

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php \Drupal\KernelTests\Core\Entity\EntityTypedDataDefinitionTest::testEntityDefinitionIsInternal()
  2. 10 core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php \Drupal\KernelTests\Core\Entity\EntityTypedDataDefinitionTest::testEntityDefinitionIsInternal()
  3. 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php \Drupal\KernelTests\Core\Entity\EntityTypedDataDefinitionTest::testEntityDefinitionIsInternal()

Tests that an entity annotation can mark the data definition as internal.

@dataProvider entityDefinitionIsInternalProvider

File

core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php, line 149

Class

EntityTypedDataDefinitionTest
Tests deriving metadata of entity and field data types.

Namespace

Drupal\KernelTests\Core\Entity

Code

public function testEntityDefinitionIsInternal($internal, $expected) {
    $entity_type_id = $this->randomMachineName();
    $entity_type = $this->prophesize(EntityTypeInterface::class);
    $entity_type->entityClassImplements(ConfigEntityInterface::class)
        ->willReturn(FALSE);
    $entity_type->getKey('bundle')
        ->willReturn(FALSE);
    $entity_type->getLabel()
        ->willReturn($this->randomString());
    $entity_type->getConstraints()
        ->willReturn([]);
    $entity_type->isInternal()
        ->willReturn($internal);
    $entity_type->getBundleEntityType()
        ->willReturn(NULL);
    $entity_type_manager = $this->prophesize(EntityTypeManagerInterface::class);
    $entity_type_manager->getDefinitions()
        ->willReturn([
        $entity_type_id => $entity_type->reveal(),
    ]);
    $this->container
        ->set('entity_type.manager', $entity_type_manager->reveal());
    $entity_data_definition = EntityDataDefinition::create($entity_type_id);
    $this->assertSame($expected, $entity_data_definition->isInternal());
}

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