You are here

protected function FieldableEntityDefinitionUpdateTest::assertTranslatable in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\FieldableEntityDefinitionUpdateTest::assertTranslatable()
  2. 10 core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php \Drupal\KernelTests\Core\Entity\FieldableEntityDefinitionUpdateTest::assertTranslatable()

Asserts the translatable characteristics of an entity type.

2 calls to FieldableEntityDefinitionUpdateTest::assertTranslatable()
FieldableEntityDefinitionUpdateTest::assertEntityTypeSchema in core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php
Asserts revisionable and/or translatable characteristics of an entity type.
FieldableEntityDefinitionUpdateTest::assertRevisionableAndTranslatable in core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php
Asserts the revisionable / translatable characteristics of an entity type.

File

core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php, line 523

Class

FieldableEntityDefinitionUpdateTest
Tests EntityDefinitionUpdateManager's fieldable entity update functionality.

Namespace

Drupal\KernelTests\Core\Entity

Code

protected function assertTranslatable() {

  /** @var \Drupal\Core\Entity\ContentEntityTypeInterface $entity_type */
  $entity_type = $this->entityDefinitionUpdateManager
    ->getEntityType($this->entityTypeId);
  $this
    ->assertTrue($entity_type
    ->isTranslatable());

  // Check that the required field definitions of a translatable entity type
  // exists and are stored in the correct tables.
  $langcode_key = $entity_type
    ->getKey('langcode');
  $default_langcode_key = $entity_type
    ->getKey('default_langcode');
  $langcode_field = $this->entityDefinitionUpdateManager
    ->getFieldStorageDefinition($langcode_key, $entity_type
    ->id());
  $default_langcode_field = $this->entityDefinitionUpdateManager
    ->getFieldStorageDefinition($default_langcode_key, $entity_type
    ->id());
  $this
    ->assertNotNull($langcode_field);
  $this
    ->assertNotNull($default_langcode_field);
  $database_schema = $this->database
    ->schema();
  $base_table = $entity_type
    ->getBaseTable();
  $data_table = $entity_type
    ->getDataTable();
  $this
    ->assertTrue($database_schema
    ->tableExists($data_table));
  $this
    ->assertTrue($database_schema
    ->fieldExists($base_table, $langcode_key));
  $this
    ->assertTrue($database_schema
    ->fieldExists($data_table, $langcode_key));
  $this
    ->assertFalse($database_schema
    ->fieldExists($base_table, $default_langcode_key));
  $this
    ->assertTrue($database_schema
    ->fieldExists($data_table, $default_langcode_key));
}