function ConfigTranslationUiModulesTest::testBooleanFieldConfigTranslation
Same name in other branches
- 10 core/modules/config_translation/tests/src/Functional/ConfigTranslationUiModulesTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationUiModulesTest::testBooleanFieldConfigTranslation()
Tests the translation of a boolean field settings.
File
-
core/
modules/ config_translation/ tests/ src/ Functional/ ConfigTranslationUiModulesTest.php, line 249
Class
- ConfigTranslationUiModulesTest
- Translate settings and entities to various languages.
Namespace
Drupal\Tests\config_translation\FunctionalCode
public function testBooleanFieldConfigTranslation() : void {
// Add a test boolean field.
$field_name = $this->randomMachineName();
FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'boolean',
])->save();
$bundle = $this->randomMachineName();
entity_test_create_bundle($bundle);
$field = FieldConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'bundle' => $bundle,
]);
$on_label = 'On label (with <em>HTML</em> & things)';
$field->setSetting('on_label', $on_label);
$off_label = 'Off label (with <em>HTML</em> & things)';
$field->setSetting('off_label', $off_label);
$field->save();
$this->drupalLogin($this->translatorUser);
$this->drupalGet("/entity_test/structure/{$bundle}/fields/entity_test.{$bundle}.{$field_name}/translate");
$this->clickLink('Add');
// Checks the text of details summary element that surrounds the translation
// options.
$this->assertSession()
->responseContains(Html::escape(strip_tags($on_label)) . ' Boolean settings');
// Checks that the correct on and off labels appear on the form.
$this->assertSession()
->assertEscaped($on_label);
$this->assertSession()
->assertEscaped($off_label);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.