function EntityFieldManagerTest::testGetBaseFieldDefinitionsTranslatableEntityTypeDefaultLangcode

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php \Drupal\Tests\Core\Entity\EntityFieldManagerTest::testGetBaseFieldDefinitionsTranslatableEntityTypeDefaultLangcode()
  2. 8.9.x core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php \Drupal\Tests\Core\Entity\EntityFieldManagerTest::testGetBaseFieldDefinitionsTranslatableEntityTypeDefaultLangcode()
  3. 11.x core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php \Drupal\Tests\Core\Entity\EntityFieldManagerTest::testGetBaseFieldDefinitionsTranslatableEntityTypeDefaultLangcode()

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

@covers ::getBaseFieldDefinitions @covers ::buildBaseFieldDefinitions

@dataProvider providerTestGetBaseFieldDefinitionsTranslatableEntityTypeDefaultLangcode

File

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

Class

EntityFieldManagerTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Entity%21EntityFieldManager.php/class/EntityFieldManager/10" title="Manages the discovery of entity fields." class="local">\Drupal\Core\Entity\EntityFieldManager</a> @group Entity

Namespace

Drupal\Tests\Core\Entity

Code

public function testGetBaseFieldDefinitionsTranslatableEntityTypeDefaultLangcode($default_langcode_key) {
    $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.