3 namespace Drupal\paragraphs\Tests\Classic;
6 * Provides helper methods for Drupal 8.3.x and 8.4.x versions.
8 trait ParagraphsCoreVersionUiTestTrait {
11 * An adapter for 8.3 > 8.4 Save (and (un)publish) node button change.
13 * Arguments are the same as WebTestBase::drupalPostForm.
15 * @see \Drupal\simpletest\WebTestBase::drupalPostForm
16 * @see https://www.drupal.org/node/2847274
18 * @param \Drupal\Core\Url|string $path
19 * Location of the post form.
21 * Field data in an associative array.
22 * @param mixed $submit
23 * Value of the submit button whose click is to be emulated. For example,
24 * @param array $options
25 * (optional) Options to be forwarded to the url generator.
26 * @param array $headers
27 * (optional) An array containing additional HTTP request headers.
28 * @param string $form_html_id
29 * (optional) HTML ID of the form to be submitted.
30 * @param string $extra_post
31 * (optional) A string of additional data to append to the POST submission.
33 protected function paragraphsPostNodeForm($path, $edit, $submit, array $options = [], array $headers = [], $form_html_id = NULL, $extra_post = NULL) {
34 $drupal_version = (float) substr(\Drupal::VERSION, 0, 3);
35 if ($drupal_version > 8.3) {
37 case t('Save and unpublish'):
39 $edit['status[value]'] = FALSE;
42 case t('Save and publish'):
44 $edit['status[value]'] = TRUE;
47 case t('Save and keep published (this translation)'):
48 $submit = t('Save (this translation)');
55 parent::drupalPostForm($path, $edit, $submit, $options, $headers, $form_html_id, $extra_post);