function LocaleTranslatedSchemaDefinitionTest::testTranslatedSchemaDefinition

Same name in other branches
  1. 9 core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php \Drupal\Tests\locale\Functional\LocaleTranslatedSchemaDefinitionTest::testTranslatedSchemaDefinition()
  2. 8.9.x core/modules/locale/tests/src/Functional/LocaleTranslatedSchemaDefinitionTest.php \Drupal\Tests\locale\Functional\LocaleTranslatedSchemaDefinitionTest::testTranslatedSchemaDefinition()
  3. 11.x 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 52

Class

LocaleTranslatedSchemaDefinitionTest
Adds and configures languages to check field schema definition.

Namespace

Drupal\Tests\locale\Functional

Code

public function testTranslatedSchemaDefinition() : void {
    
    /** @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());
}

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