You are here

function LocaleTranslatedSchemaDefinitionTest::testTranslatedSchemaDefinition in Zircon Profile 8.0

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

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

File

core/modules/locale/src/Tests/LocaleTranslatedSchemaDefinitionTest.php, line 44
Contains \Drupal\locale\Tests\LocaleTranslatedSchemaDefinitionTest.

Class

LocaleTranslatedSchemaDefinitionTest
Adds and configures languages to check field schema definition.

Namespace

Drupal\locale\Tests

Code

function testTranslatedSchemaDefinition() {

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

  // Ensure that the field is translated when access through the API.
  $this
    ->assertEqual('Translated node ID', \Drupal::entityManager()
    ->getBaseFieldDefinitions('node')['nid']
    ->getDescription());

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