Skip to content
Snippets Groups Projects

Issue #3262149: New non-translatable field on translatable paragraph throws error

1 file
+ 52
0
Compare changes
  • Side-by-side
  • Inline
@@ -840,6 +840,58 @@ class ParagraphsTranslationTest extends ParagraphsTestBase {
$this->assertParagraphsLangcode($node2->id(), 'de');
}
/**
* Test adding a new non-translatable field to translatable paragraph.
*/
public function testNewNonTranslatableField() {
// Hide untranslatable fields from the "text_image" paragraph form.
$edit = [
'settings[paragraph][text_image][settings][content_translation][untranslatable_fields_hide]' => TRUE,
];
$this->drupalGet('admin/config/regional/content-language');
$this->submitForm($edit, 'Save configuration');
// Use the stable widget.
$form_display = EntityFormDisplay::load('paragraph.nested_paragraph.default')
->setComponent('field_paragraphs_demo', [
'type' => 'paragraphs',
]);
$form_display->save();
// Create paragraphed_content_demo node.
$this->drupalGet('node/add/paragraphed_content_demo');
$this->submitForm([], 'Add text_image');
$edit = [
'title[0][value]' => 'example_publish_unpublish',
'field_paragraphs_demo[0][subform][field_text_demo][0][value]' => 'Example published and unpublished',
];
$this->submitForm($edit, 'Save');
$node = $this->drupalGetNodeByTitle('example_publish_unpublish');
// Add an untranslatable field to the 'text' paragraph.
static::fieldUIAddNewField('admin/structure/paragraphs_type/text_image', 'boolean', 'Boolean', 'boolean', [
'cardinality' => "number",
'cardinality_number' => "1",
], [
'translatable' => "0",
]);
$this->drupalGet('node/' . $node->id());
// Add french translation.
$this->clickLink('Translate');
$this->clickLink('Add', 1);
$edit = array(
'title[0][value]' => 'Title in french',
'field_paragraphs_demo[0][subform][field_text_demo][0][value]' => 'Text in french',
'revision' => TRUE,
'revision_log[0][value]' => 'french 1',
);
$this->submitForm($edit, 'Save (this translation)');
$this->assertSession()->pageTextNotContains('Non-translatable fields can only be changed when updating the original language.');
}
/**
* Passes if the paragraphs buttons are present.
*
Loading