function EntityFieldManagerTest::testGetBaseFieldDefinitionsTranslatableEntityTypeDefaultLangcode

Tests the getBaseFieldDefinitions() method with a translatable entity type.

@legacy-covers ::getBaseFieldDefinitions @legacy-covers ::buildBaseFieldDefinitions

Attributes

#[DataProvider('providerTestGetBaseFieldDefinitionsTranslatableEntityTypeDefaultLangcode')]

File

core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php, line 344

Class

EntityFieldManagerTest
Tests Drupal\Core\Entity\EntityFieldManager.

Namespace

Drupal\Tests\Core\Entity

Code

public function testGetBaseFieldDefinitionsTranslatableEntityTypeDefaultLangcode($default_langcode_key) : void {
  $this->setUpEntityWithFieldDefinition(FALSE, 'id', [
    'langcode' => 'langcode',
    'default_langcode' => $default_langcode_key,
  ]);
  $field_definition = $this->prophesize()
    ->willImplement(FieldDefinitionInterface::class)
    ->willImplement(FieldStorageDefinitionInterface::class);
  $field_definition->isTranslatable()
    ->willReturn(TRUE);
  $entity_class = EntityTypeManagerTestEntity::class;
  $entity_class::$baseFieldDefinitions += [
    'langcode' => $field_definition,
  ];
  $this->entityType
    ->isTranslatable()
    ->willReturn(TRUE);
  $definitions = $this->entityFieldManager
    ->getBaseFieldDefinitions('test_entity_type');
  $this->assertTrue(isset($definitions[$default_langcode_key]));
}

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