function ConfigTranslationUiTest::testBooleanFieldConfigTranslation
Same name in other branches
- 8.9.x core/modules/config_translation/tests/src/Functional/ConfigTranslationUiTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationUiTest::testBooleanFieldConfigTranslation()
Tests the translation of a boolean field settings.
File
-
core/
modules/ config_translation/ tests/ src/ Functional/ ConfigTranslationUiTest.php, line 786
Class
- ConfigTranslationUiTest
- Translate settings and entities to various languages.
Namespace
Drupal\Tests\config_translation\FunctionalCode
public function testBooleanFieldConfigTranslation() {
// Add a test boolean field.
$field_name = strtolower($this->randomMachineName());
FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'boolean',
])->save();
$bundle = strtolower($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.