public function ParagraphsConfigTest::testContentTranslationForm in Paragraphs 8
Same name in this branch
- 8 tests/src/Functional/WidgetLegacy/ParagraphsConfigTest.php \Drupal\Tests\paragraphs\Functional\WidgetLegacy\ParagraphsConfigTest::testContentTranslationForm()
- 8 tests/src/Functional/WidgetStable/ParagraphsConfigTest.php \Drupal\Tests\paragraphs\Functional\WidgetStable\ParagraphsConfigTest::testContentTranslationForm()
Tests content translation form translatability constraints messages.
File
- tests/
src/ Functional/ WidgetStable/ ParagraphsConfigTest.php, line 73
Class
- ParagraphsConfigTest
- Tests paragraphs configuration.
Namespace
Drupal\Tests\paragraphs\Functional\WidgetStableCode
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::create([
'id' => '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');
$edit = [
'new_storage_type' => 'field_ui:entity_reference:node',
'label' => 'new_no_field_paragraphs',
'field_name' => 'new_no_field_paragraphs',
];
$this
->submitForm($edit, 'Save and continue');
$this
->submitForm([], 'Save field settings');
$this
->assertSession()
->pageTextNotContains('Paragraphs fields do not support translation.');
$this
->assertSession()
->responseNotContains('<div class="messages messages--warning');
}