function ConfigTranslationUiModulesTest::testNodeFieldTranslation
Same name in other branches
- 10 core/modules/config_translation/tests/src/Functional/ConfigTranslationUiModulesTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationUiModulesTest::testNodeFieldTranslation()
Tests field translation for node fields.
File
-
core/
modules/ config_translation/ tests/ src/ Functional/ ConfigTranslationUiModulesTest.php, line 385
Class
- ConfigTranslationUiModulesTest
- Translate settings and entities to various languages.
Namespace
Drupal\Tests\config_translation\FunctionalCode
public function testNodeFieldTranslation() : void {
NodeType::create([
'type' => 'article',
'name' => 'Article',
])->save();
$field_name = 'translatable_field';
$field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'node',
'type' => 'text',
]);
$field_storage->setSetting('translatable_storage_setting', 'translatable_storage_setting');
$field_storage->save();
$field = FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => 'article',
]);
$field->save();
$this->drupalLogin($this->translatorUser);
$this->drupalGet("/entity_test/structure/article/fields/node.article.{$field_name}/translate");
$this->clickLink('Add');
$form_values = [
'translation[config_names][field.field.node.article.translatable_field][description]' => 'FR Help text.',
'translation[config_names][field.field.node.article.translatable_field][label]' => 'FR label',
];
$this->submitForm($form_values, 'Save translation');
$this->assertSession()
->pageTextContains('Successfully saved French translation.');
// Check that the translations are saved.
$this->clickLink('Edit');
$this->assertSession()
->responseContains('FR label');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.