public function ContentTranslationSettingsTest::testFieldTranslatableSettingsUI in Drupal 8
Same name and namespace in other branches
- 9 core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationSettingsTest::testFieldTranslatableSettingsUI()
Tests that field setting depends on bundle translatability.
File
- core/
modules/ content_translation/ tests/ src/ Functional/ ContentTranslationSettingsTest.php, line 271
Class
- ContentTranslationSettingsTest
- Tests the content translation settings UI.
Namespace
Drupal\Tests\content_translation\FunctionalCode
public function testFieldTranslatableSettingsUI() {
// At least one field needs to be translatable to enable article for
// translation. Create an extra field to be used for this purpose. We use
// the UI to test our form alterations.
$edit = [
'new_storage_type' => 'text',
'label' => 'Test',
'field_name' => 'article_text',
];
$this
->drupalPostForm('admin/structure/types/manage/article/fields/add-field', $edit, 'Save and continue');
// Tests that field doesn't have translatable setting if bundle is not
// translatable.
$path = 'admin/structure/types/manage/article/fields/node.article.field_article_text';
$this
->drupalGet($path);
$this
->assertFieldByXPath('//input[@id="edit-translatable" and @disabled="disabled"]');
$this
->assertText('To configure translation for this field, enable language support for this type.', 'No translatable setting for field.');
// Tests that field has translatable setting if bundle is translatable.
// Note: this field is not translatable when enable bundle translatability.
$edit = [
'entity_types[node]' => TRUE,
'settings[node][article][settings][language][language_alterable]' => TRUE,
'settings[node][article][translatable]' => TRUE,
'settings[node][article][fields][field_article_text]' => TRUE,
];
$this
->assertSettings('node', 'article', TRUE, $edit);
$this
->drupalGet($path);
$this
->assertFieldByXPath('//input[@id="edit-translatable" and not(@disabled) and @checked="checked"]');
$this
->assertNoText('To enable translation of this field, enable language support for this type.', 'Translatable setting for field available.');
}