Tests content translation form translatability constraints messages.
public function testContentTranslationForm() {
$this
->loginAsAdmin([
'administer languages',
'administer content translation',
'create content translations',
'translate any entity',
]);
// Check warning message is displayed.
$this
->drupalGet('admin/config/regional/content-language');
$this
->assertSession()
->pageTextContains('(* unsupported) Paragraphs fields do not support translation.');
$this
->addParagraphedContentType('paragraphed_test');
// Check error message is not displayed.
$this
->drupalGet('admin/config/regional/content-language');
$this
->assertSession()
->pageTextContains('(* unsupported) Paragraphs fields do not support translation.');
$this
->assertSession()
->responseNotContains('<div class="messages messages--error');
// Add a second language.
ConfigurableLanguage::createFromLangcode('de')
->save();
// Enable translation for paragraphed content type.
$edit = [
'entity_types[node]' => TRUE,
'settings[node][paragraphed_test][translatable]' => TRUE,
'settings[node][paragraphed_test][fields][field_paragraphs]' => FALSE,
];
$this
->drupalGet('admin/config/regional/content-language');
$this
->submitForm($edit, 'Save configuration');
// Check error message is still not displayed.
$this
->drupalGet('admin/config/regional/content-language');
$this
->assertSession()
->pageTextContains('(* unsupported) Paragraphs fields do not support translation.');
$this
->assertSession()
->responseNotContains('<div class="messages messages--error');
// Check content type field management warning.
$this
->drupalGet('admin/structure/types/manage/paragraphed_test/fields/node.paragraphed_test.field_paragraphs');
$this
->assertSession()
->pageTextContains('Paragraphs fields do not support translation.');
// Make the paragraphs field translatable.
$edit = [
'entity_types[node]' => TRUE,
'settings[node][paragraphed_test][translatable]' => TRUE,
'settings[node][paragraphed_test][fields][field_paragraphs]' => TRUE,
];
$this
->drupalGet('admin/config/regional/content-language');
$this
->submitForm($edit, 'Save configuration');
// Check content type field management error.
$this
->drupalGet('admin/structure/types/manage/paragraphed_test/fields/node.paragraphed_test.field_paragraphs');
$this
->assertSession()
->pageTextContains('Paragraphs fields do not support translation.');
$this
->assertSession()
->responseContains('<div class="messages messages--error');
// Check a not paragraphs translatable field does not display the message.
$this
->drupalGet('admin/structure/types/manage/paragraphed_test/fields/add-field');
$selected_group = [
'new_storage_type' => 'reference',
];
$this
->submitForm($selected_group, $this
->coreVersion('10.3') ? 'Continue' : 'Change field group');
$edit = [
'group_field_options_wrapper' => 'field_ui:entity_reference:node',
'label' => 'new_no_field_paragraphs',
'field_name' => 'new_no_field_paragraphs',
];
$this
->submitForm($edit, 'Continue');
$this
->assertSession()
->pageTextNotContains('Paragraphs fields do not support translation.');
$this
->assertSession()
->responseNotContains('<div class="messages messages--warning');
}