use Drupal\Core\Language\LanguageInterface;
use Drupal\paragraphs\Entity\Paragraph;
use Drupal\node\Entity\Node;
+use Drupal\user\Entity\Role;
/**
* Tests the configuration of paragraphs.
'settings[paragraph][images][fields][field_images_demo]' => TRUE,
];
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
+
+ if (version_compare(\Drupal::VERSION, '8.4', '>=')) {
+ // @todo Workaround for file usage/unable to save the node with no usages.
+ // Remove when https://www.drupal.org/node/2801777 is fixed.
+ \Drupal::configFactory()->getEditable('file.settings')
+ ->set('make_unused_managed_files_temporary', TRUE)
+ ->save();
+ }
}
/**
* Tests the paragraph translation.
*/
public function testParagraphTranslation() {
+ // We need to add a permission to administer roles to deal with revisions.
+ $roles = $this->loggedInUser->getRoles();
+ $this->grantPermissions(Role::load(array_shift($roles)), ['administer nodes']);
$this->drupalGet('admin/config/regional/content-language');
// Check the settings are saved correctly.
'title[0][value]' => 'example_publish_unpublish',
'field_paragraphs_demo[0][subform][field_text_demo][0][value]' => 'Example published and unpublished',
];
- $this->drupalPostForm(NULL, $edit, t('Save and publish'));
+ $this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertText(t('Example published and unpublished'));
$this->clickLink(t('Edit'));
'field_paragraphs_demo[0][subform][status][value]' => FALSE,
'field_paragraphs_demo[1][subform][field_paragraphs_demo][0][subform][field_text_demo][0][value]' => 'Dummy text'
];
- $this->drupalPostForm(NULL, $edit, t('Save and keep published'));
+ $this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertNoText(t('Example published and unpublished'));
// Check the parent fields are set properly. Get the node.
);
// The button to remove a paragraph is present.
$this->assertRaw(t('Remove'));
- $this->drupalPostForm(NULL, $edit, t('Save and publish'));
+ $this->drupalPostForm(NULL, $edit, t('Save'));
$node = $this->drupalGetNodeByTitle('Title in english');
// The text is present when editing again.
$this->clickLink(t('Edit'));
'revision' => TRUE,
'revision_log[0][value]' => 'french 1',
);
- $this->drupalPostForm(NULL, $edit, t('Save and keep published (this translation)'));
+ $this->drupalPostForm(NULL, $edit, t('Save (this translation)'));
$this->assertText('Paragraphed article Title in french has been updated.');
// Check the english translation.
'revision' => TRUE,
'revision_log[0][value]' => 'french 2',
);
- $this->drupalPostForm(NULL, $edit, t('Save and keep published (this translation)'));
+ $this->drupalPostForm(NULL, $edit, t('Save (this translation)'));
$this->assertText('Title Change in french');
$this->assertText('New text in french');
$this->assertText('Title in english');
$this->assertText('Text in english');
// Save the original content on second request.
- $this->drupalPostForm(NULL, NULL, t('Save and keep published (this translation)'));
+ $this->drupalPostForm(NULL, NULL, t('Save (this translation)'));
$this->assertText('Paragraphed article Title in english has been updated.');
// Test if reverting to old paragraphs revisions works, make sure that
$this->clickLink(t('Edit'));
$this->assertRaw('Title in french');
$this->assertText('Text in french');
- $this->drupalPostForm(NULL, [], t('Save and keep published (this translation)'));
+ $this->drupalPostForm(NULL, [], t('Save (this translation)'));
$this->assertNoRaw('The content has either been modified by another user, or you have already submitted modifications');
$this->assertText('Text in french');
'field_paragraphs_demo[0][subform][field_images_demo][0][width]' => 100,
'field_paragraphs_demo[0][subform][field_images_demo][0][height]' => 100,
];
- $this->drupalPostForm(NULL, $edit, t('Save and publish'));
+ $this->drupalPostForm(NULL, $edit, t('Save'));
// Translate the node with the image paragraph.
$this->clickLink('Translate');
'field_paragraphs_demo[0][subform][field_images_demo][0][alt]' => 'Image alt FR',
'field_paragraphs_demo[0][subform][field_images_demo][0][title]' => 'Image title FR',
];
- $this->drupalPostForm(NULL, $edit, t('Save and keep published (this translation)'));
+ $this->drupalPostForm(NULL, $edit, t('Save (this translation)'));
$this->assertRaw('Title FR');
$this->drupalGet('node/add/paragraphed_content_demo');
'title[0][value]' => 'titulo',
'langcode[0][value]' => 'de',
];
- $this->drupalPostForm(NULL, $edit, t('Save and publish'));
+ $this->drupalPostForm(NULL, $edit, t('Save'));
$node = $this->drupalGetNodeByTitle('titulo');
$this->assertParagraphsLangcode($node->id(), 'de');
'field_paragraphs_demo' => [$paragraph_1, $translated_paragraph],
]);
$this->drupalGet('node/' . $node->id() . '/edit');
- $this->drupalPostForm(NULL, [], t('Save and keep published'));
+ $this->drupalPostForm(NULL, [], t('Save'));
$this->assertText('Paragraphed article ' . $node->label() . ' has been updated.');
// Check that first paragraph langcode has been updated.
$paragraph = Paragraph::load($paragraph_1->id());
'field_paragraphs_demo[0][subform][field_text_demo][0][value]' => 'english_translation_1',
'field_paragraphs_demo[1][subform][field_text_demo][0][value]' => 'english_translation_2',
];
- $this->drupalPostForm('node/' . $node->id() . '/translations/add/de/en', $edit, t('Save and keep published (this translation)'));
+ $this->drupalPostForm('node/' . $node->id() . '/translations/add/de/en', $edit, t('Save (this translation)'));
// Attempt to create a french translation.
$this->drupalGet('node/' . $node->id() . '/translations/add/de/fr');
// Check that the german translation of the paragraphs is displayed.
// Create a node with empty Paragraphs.
$this->drupalGet('node/add/paragraphed_content_demo');
$this->drupalPostForm(NULL, [], t('Add Nested Paragraph'));
- $this->drupalPostForm(NULL, ['title[0][value]' => 'empty_node'], t('Save and publish'));
+ $edit = ['title[0][value]' => 'empty_node'];
+ $this->drupalPostForm(NULL, $edit, t('Save'));
// Attempt to translate it.
$this->clickLink(t('Translate'));
$this->clickLink(t('Add'));
];
$this->drupalPostForm(NULL, $edit, t('Upload'));
$this->assertParagraphsButtons(1);
- $this->drupalPostForm(NULL, NULL, t('Save and publish'));
+ $this->drupalPostForm(NULL, NULL, t('Save'));
$this->assertText('Title in english');
$node = $this->drupalGetNodeByTitle('Title in english');
// Check the paragraph langcode is 'en'.
$edit = [
'title[0][value]' => 'Title in french',
];
- $this->drupalPostForm(NULL, $edit, t('Save and keep published (this translation)'));
+ $this->drupalPostForm(NULL, $edit, t('Save (this translation)'));
$this->assertParagraphsLangcode($node->id(), 'en', 'fr');
$this->assertText('Paragraphed article Title in french has been updated.');
$this->assertText('Title in french');
// check that the paragraphs buttons are still hidden.
$this->assertParagraphsLangcode($node->id(), 'en', 'fr');
$this->assertNoParagraphsButtons(1);
- $this->drupalPostForm(NULL, NULL, t('Save and keep published (this translation)'));
+ $this->drupalPostForm(NULL, NULL, t('Save (this translation)'));
$this->assertText('Title in french');
$this->assertNoText('Title in english');
], t('Upload'));
$this->assertParagraphsLangcode($node->id());
$this->assertParagraphsButtons(2);
- $this->drupalPostForm(NULL, NULL, t('Save and keep published (this translation)'));
+ $this->drupalPostForm(NULL, NULL, t('Save (this translation)'));
$this->assertText('Title in english (de)');
$this->assertNoText('Title in french');
// Check the original node and the paragraphs langcode are now 'de'.
// check that the paragraphs buttons are still hidden.
$this->assertParagraphsLangcode($node->id(), 'de', 'fr');
$this->assertNoParagraphsButtons(2);
- $this->drupalPostForm(NULL, NULL, t('Save and keep published (this translation)'));
+ $this->drupalPostForm(NULL, NULL, t('Save (this translation)'));
// Check the paragraphs langcode are still 'de' after saving the translation.
$this->assertParagraphsLangcode($node->id(), 'de', 'fr');
$this->assertText('Title in french');
], t('Upload'));
$this->assertParagraphsLangcode($node->id(), 'de');
$this->assertParagraphsButtons(3);
- $this->drupalPostForm(NULL, NULL, t('Save and keep published (this translation)'));
+ $this->drupalPostForm(NULL, NULL, t('Save (this translation)'));
// Check the original node and the paragraphs langcode are now 'en'.
$this->assertParagraphsLangcode($node->id());
}
'files[field_paragraphs_demo_0_subform_field_paragraphs_demo_0_subform_field_images_demo_0][]' => $images->uri,
], t('Upload'));
$this->assertParagraphsButtons(1);
- $this->drupalPostForm(NULL, NULL, t('Save and publish'));
+ $this->drupalPostForm(NULL, NULL, t('Save'));
$this->assertText('Title in german');
$node1 = $this->getNodeByTitle('Title in german');
// Check the paragraph langcode is still 'de' and its buttons are shown.
$this->assertParagraphsLangcode($node1->id(), 'de');
$this->assertParagraphsButtons(1);
- $this->drupalPostForm(NULL, NULL, t('Save and keep published'));
+ $this->drupalPostForm(NULL, NULL, t('Save'));
// Check the paragraph langcode is now 'en' after saving.
$this->assertParagraphsLangcode($node1->id());
];
$this->drupalPostForm(NULL, $edit, t('Upload'));
$this->assertParagraphsButtons(1);
- $this->drupalPostForm(NULL, NULL, t('Save and publish'));
+ $this->drupalPostForm(NULL, NULL, t('Save'));
$this->assertText('Title in english');
$node2 = $this->drupalGetNodeByTitle('Title in english');
], t('Upload'));
$this->assertParagraphsLangcode($node2->id());
$this->assertParagraphsButtons(2);
- $this->drupalPostForm(NULL, NULL, t('Save and keep published'));
+ $this->drupalPostForm(NULL, NULL, t('Save'));
// Check the paragraphs langcode are now 'de' after saving.
$this->assertParagraphsLangcode($node2->id(), 'de');
'title[0][value]' => 'Title in english',
'langcode[0][value]' => 'en',
];
- $this->drupalPostForm(NULL, $edit, t('Save and keep published'));
+ $this->drupalPostForm(NULL, $edit, t('Save'));
// Check the paragraphs langcode are now 'en' after saving.
$this->assertParagraphsLangcode($node2->id());
], t('Upload'));
$this->assertParagraphsLangcode($node2->id());
$this->assertParagraphsButtons(3);
- $this->drupalPostForm(NULL, NULL, t('Save and keep published'));
+ $this->drupalPostForm(NULL, NULL, t('Save'));
// Check the paragraphs langcode are still 'en' after saving.
$this->assertParagraphsLangcode($node2->id());
], t('Upload'));
$this->assertParagraphsLangcode($node2->id());
$this->assertParagraphsButtons(4);
- $this->drupalPostForm(NULL, NULL, t('Save and keep published'));
+ $this->drupalPostForm(NULL, NULL, t('Save'));
// Check the paragraphs langcode are now 'de' after saving.
$this->assertParagraphsLangcode($node2->id(), 'de');
}