3 namespace Drupal\paragraphs\Tests\Classic;
6 * Tests the translation of heavily nested / specialized setup.
10 class ParagraphsEntityTranslationWithNonTranslatableParagraphs extends ParagraphsTestBase {
17 public static $modules = [
19 'content_translation',
25 protected function setUp() {
28 $this->admin_user = $this->drupalCreateUser([], NULL, TRUE);
29 $this->drupalLogin($this->admin_user);
33 'predefined_langcode' => 'de',
35 $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
37 'predefined_langcode' => 'fr',
39 $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
41 // Create article content type with a paragraphs field.
42 $this->addParagraphedContentType('article', 'field_paragraphs');
43 $this->drupalGet('admin/structure/types/manage/article');
44 // Make content type translatable.
46 'language_configuration[content_translation]' => TRUE,
48 $this->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type'));
49 $this->drupalGet('admin/structure/types/manage/article');
51 // Ensue the paragraphs field itself isn't translatable - this would be a
52 // currently not supported configuration otherwise.
54 'translatable' => FALSE,
56 $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.field_paragraphs', $edit, t('Save settings'));
58 // Add Paragraphs type.
59 $this->addParagraphsType('test_paragraph_type');
60 // Configure paragraphs type.
61 static::fieldUIAddNewField('admin/structure/paragraphs_type/test_paragraph_type', 'text', 'Text', 'string', [
62 'cardinality' => '-1',
65 // Just for verbose-sake - check the content language settings.
66 $this->drupalGet('admin/config/regional/content-language');
70 * Tests the revision of paragraphs.
72 public function testParagraphsIEFTranslation() {
73 $this->drupalLogin($this->admin_user);
75 // Create node with one paragraph.
76 $this->drupalGet('node/add/article');
78 // Set the values and save.
80 'title[0][value]' => 'Title English',
82 $this->drupalPostForm(NULL, $edit, t('Save'));
84 // Add french translation.
85 $this->clickLink(t('Translate'));
86 $this->clickLink(t('Add'), 1);
87 // Make sure that the original paragraph text is displayed.
88 $this->assertText('Title English');
91 'title[0][value]' => 'Title French',
93 $this->drupalPostForm(NULL, $edit, t('Save (this translation)'));
94 $this->assertText('article Title French has been updated.');
96 // Add german translation.
97 $this->clickLink(t('Translate'));
98 $this->clickLink(t('Add'));
99 // Make sure that the original paragraph text is displayed.
100 $this->assertText('Title English');
103 'title[0][value]' => 'Title German',
105 $this->drupalPostForm(NULL, $edit, t('Save (this translation)'));
106 $this->assertText('article Title German has been updated.');