function EntityFieldManagerTest::testGetBaseFieldDefinitionsTranslatableEntityTypeLangcode
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php \Drupal\Tests\Core\Entity\EntityFieldManagerTest::testGetBaseFieldDefinitionsTranslatableEntityTypeLangcode()
- 8.9.x core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php \Drupal\Tests\Core\Entity\EntityFieldManagerTest::testGetBaseFieldDefinitionsTranslatableEntityTypeLangcode()
- 10 core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php \Drupal\Tests\Core\Entity\EntityFieldManagerTest::testGetBaseFieldDefinitionsTranslatableEntityTypeLangcode()
Tests the getBaseFieldDefinitions() method with a translatable entity type.
@covers ::getBaseFieldDefinitions @covers ::buildBaseFieldDefinitions
@dataProvider providerTestGetBaseFieldDefinitionsTranslatableEntityTypeLangcode
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityFieldManagerTest.php, line 379
Class
- EntityFieldManagerTest
- @coversDefaultClass \Drupal\Core\Entity\EntityFieldManager @group Entity
Namespace
Drupal\Tests\Core\EntityCode
public function testGetBaseFieldDefinitionsTranslatableEntityTypeLangcode($provide_key, $provide_field, $translatable) : void {
$keys = $provide_key ? [
'langcode' => 'langcode',
] : [];
$this->setUpEntityWithFieldDefinition(FALSE, 'id', $keys);
if ($provide_field) {
$field_definition = $this->prophesize()
->willImplement(FieldDefinitionInterface::class)
->willImplement(FieldStorageDefinitionInterface::class);
$field_definition->isTranslatable()
->willReturn($translatable);
if (!$translatable) {
$field_definition->setTranslatable(!$translatable)
->shouldBeCalled();
}
$entity_class = EntityTypeManagerTestEntity::class;
$entity_class::$baseFieldDefinitions += [
'langcode' => $field_definition->reveal(),
];
}
$this->entityType
->isTranslatable()
->willReturn(TRUE);
$this->entityType
->getLabel()
->willReturn('Test');
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('The Test entity type cannot be translatable as it does not define a translatable "langcode" field.');
$this->entityFieldManager
->getBaseFieldDefinitions('test_entity_type');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.