function ConfigTranslationUiModulesTest::testFieldConfigTranslation
Same name in other branches
- 10 core/modules/config_translation/tests/src/Functional/ConfigTranslationUiModulesTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationUiModulesTest::testFieldConfigTranslation()
Tests the translation of field and field storage configuration.
File
-
core/
modules/ config_translation/ tests/ src/ Functional/ ConfigTranslationUiModulesTest.php, line 209
Class
- ConfigTranslationUiModulesTest
- Translate settings and entities to various languages.
Namespace
Drupal\Tests\config_translation\FunctionalCode
public function testFieldConfigTranslation() : void {
// Add a test field which has a translatable field setting and a
// translatable field storage setting.
$field_name = $this->randomMachineName();
$field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'test_field',
]);
$translatable_storage_setting = $this->randomString();
$field_storage->setSetting('translatable_storage_setting', $translatable_storage_setting);
$field_storage->save();
$bundle = $this->randomMachineName();
entity_test_create_bundle($bundle);
$field = FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => $bundle,
]);
$translatable_field_setting = $this->randomString();
$field->setSetting('translatable_field_setting', $translatable_field_setting);
$field->save();
$this->drupalLogin($this->translatorUser);
$this->drupalGet("/entity_test/structure/{$bundle}/fields/entity_test.{$bundle}.{$field_name}/translate");
$this->clickLink('Add');
$this->assertSession()
->pageTextContains('Translatable field setting');
$this->assertSession()
->assertEscaped($translatable_field_setting);
$this->assertSession()
->pageTextContains('Translatable storage setting');
$this->assertSession()
->assertEscaped($translatable_storage_setting);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.