You are here

public function LocaleTranslatedSchemaDefinitionTest::testTranslatedSchemaDefinition in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php \Drupal\Tests\locale\Functional\LocaleTranslatedSchemaDefinitionTest::testTranslatedSchemaDefinition()
  2. 9 core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php \Drupal\Tests\locale\Functional\LocaleTranslatedSchemaDefinitionTest::testTranslatedSchemaDefinition()

Tests that translated field descriptions do not affect the update system.

File

core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php, line 46

Class

LocaleTranslatedSchemaDefinitionTest
Adds and configures languages to check field schema definition.

Namespace

Drupal\Tests\locale\Functional

Code

public function testTranslatedSchemaDefinition() {

  /** @var \Drupal\locale\StringDatabaseStorage $stringStorage */
  $stringStorage = \Drupal::service('locale.storage');
  $source = $stringStorage
    ->createString([
    'source' => 'Revision ID',
  ])
    ->save();
  $stringStorage
    ->createTranslation([
    'lid' => $source->lid,
    'language' => 'fr',
    'translation' => 'Translated Revision ID',
  ])
    ->save();

  // Ensure that the field is translated when access through the API.
  $this
    ->assertEquals('Translated Revision ID', \Drupal::service('entity_field.manager')
    ->getBaseFieldDefinitions('node')['vid']
    ->getLabel());

  // Assert there are no updates.
  $this
    ->assertFalse(\Drupal::service('entity.definition_update_manager')
    ->needsUpdates());
}