diff --git a/modules/paragraphs_demo/src/Tests/ParagraphsDemoTest.php b/modules/paragraphs_demo/src/Tests/ParagraphsDemoTest.php index 4aa19bc..e9b9483 100644 --- a/modules/paragraphs_demo/src/Tests/ParagraphsDemoTest.php +++ b/modules/paragraphs_demo/src/Tests/ParagraphsDemoTest.php @@ -142,7 +142,7 @@ class ParagraphsDemoTest extends WebTestBase { $edit = [ 'field_paragraphs_demo[1][subform][field_user_demo][0][target_id]' => $admin_user->label() . ' (' . $admin_user->id() . ')', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->assertText('Paragraphed article Paragraph title has been created.'); $this->assertText('Paragraph title'); diff --git a/modules/paragraphs_type_permissions/src/Tests/ParagraphsTypePermissionsTest.php b/modules/paragraphs_type_permissions/src/Tests/ParagraphsTypePermissionsTest.php index c73bf01..b4a6c2d 100644 --- a/modules/paragraphs_type_permissions/src/Tests/ParagraphsTypePermissionsTest.php +++ b/modules/paragraphs_type_permissions/src/Tests/ParagraphsTypePermissionsTest.php @@ -92,7 +92,7 @@ class ParagraphsTypePermissionsTest extends WebTestBase { 'field_paragraphs_demo[0][subform][field_text_demo][0][value]' => 'Paragraph type Image + Text', 'field_paragraphs_demo[2][subform][field_text_demo][0][value]' => 'Paragraph type Text', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); // Get the node to edit it later. $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); @@ -139,7 +139,7 @@ class ParagraphsTypePermissionsTest extends WebTestBase { $edit = [ 'field_paragraphs_demo[0][subform][status][value]' => FALSE, ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); // Check that 'Image + Text' paragraph is not shown anymore for admin user. $this->assertNoRaw($image_text_tag); diff --git a/src/Tests/Classic/ParagraphsAccessTest.php b/src/Tests/Classic/ParagraphsAccessTest.php index b12d7d9..f4f34c0 100644 --- a/src/Tests/Classic/ParagraphsAccessTest.php +++ b/src/Tests/Classic/ParagraphsAccessTest.php @@ -95,7 +95,7 @@ class ParagraphsAccessTest extends ParagraphsTestBase { $image_url = file_url_transform_relative($img1_url); $this->assertRaw($image_url, 'Image was found in preview'); $this->clickLink(t('Back to content editing')); - $this->drupalPostFormSave(NULL, [], 'Save and publish', 'Save', ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, [], t('Save and publish')); $node = $this->drupalGetNodeByTitle('Security test node'); @@ -130,7 +130,7 @@ class ParagraphsAccessTest extends ParagraphsTestBase { 'title[0][value]' => 'delete_permissions', 'field_paragraphs_demo[0][subform][field_text_demo][0][value]' => 'Test', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); // Edit the node. $this->clickLink(t('Edit')); // Check the remove button is present. @@ -138,7 +138,7 @@ class ParagraphsAccessTest extends ParagraphsTestBase { // Delete the Paragraph and save. $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_demo_0_remove'); $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_demo_0_confirm_remove'); - $this->drupalPostFormSave(NULL, [], t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and keep published')); $node = $this->getNodeByTitle('delete_permissions'); $this->assertUrl('node/' . $node->id()); } diff --git a/src/Tests/Classic/ParagraphsAddModesTest.php b/src/Tests/Classic/ParagraphsAddModesTest.php index f110fbf..b06a2db 100644 --- a/src/Tests/Classic/ParagraphsAddModesTest.php +++ b/src/Tests/Classic/ParagraphsAddModesTest.php @@ -190,7 +190,7 @@ class ParagraphsAddModesTest extends ParagraphsTestBase { $this->setDefaultParagraphType('paragraphed_test', 'paragraphs', 'paragraphs_settings_edit', 'text_image'); $this->removeDefaultParagraphType('paragraphed_test'); $edit = ['title[0][value]' => 'New Host']; - $this->drupalPostFormSave(NULL, $edit, 'Save and publish', 'Save', $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->drupalGet('node/1/edit'); $this->assertText('No Paragraph added yet.'); } diff --git a/src/Tests/Classic/ParagraphsAdministrationTest.php b/src/Tests/Classic/ParagraphsAdministrationTest.php index b111028..fb2ab91 100644 --- a/src/Tests/Classic/ParagraphsAdministrationTest.php +++ b/src/Tests/Classic/ParagraphsAdministrationTest.php @@ -71,7 +71,7 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase { 'field_paragraphs[0][subform][field_text][0][value]' => 'Test text 1', 'field_paragraphs[1][subform][field_text][0][value]' => 'Test text 2', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $node = $this->drupalGetNodeByTitle('TEST TITEL'); $paragraph1 = $node->field_paragraphs[0]->target_id; @@ -85,7 +85,7 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase { 'field_paragraphs[0][subform][field_text][0][value]' => 'Foo Bar 1', 'revision' => FALSE, ]; - $this->drupalPostFormSave('node/' . $node->id() . '/edit', $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); $this->countRevisions($node, $paragraph1, $paragraph2, 1); @@ -96,7 +96,7 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase { 'field_paragraphs[0][subform][field_text][0][value]' => 'Foo Bar 2', 'revision' => TRUE, ]; - $this->drupalPostFormSave('node/' . $node->id() . '/edit', $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); $this->countRevisions($node, $paragraph1, $paragraph2, 2); @@ -241,7 +241,7 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase { 'field_paragraphs[1][subform][field_text][0][value]' => 'Test text 2', 'files[field_paragraphs_1_subform_field_image_0]' => drupal_realpath('temporary://myImage2.jpg'), ); - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $node = $this->drupalGetNodeByTitle('Test article'); $img1_url = file_create_url(\Drupal::token()->replace('public://[date:custom:Y]-[date:custom:m]/myImage1.jpg')); @@ -325,7 +325,7 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase { 'field_paragraphs[0][subform][field_image][0][width]' => 300, 'field_paragraphs[0][subform][field_image][0][height]' => 300, ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); // Assert the paragraph is deleted after the user saves the node. $this->drupalGet('node/' . $node->id() . '/edit'); $this->assertNoRaw('myImage2.jpg'); @@ -350,13 +350,13 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase { 'title[0][value]' => 'Example publish/unpublish', 'field_paragraphs[0][subform][field_text][0][value]' => 'Example published and unpublished', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->assertText(t('Example published and unpublished')); $this->clickLink(t('Edit')); $edit = [ 'field_paragraphs[0][subform][status][value]' => FALSE, ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); $this->assertNoText(t('Example published and unpublished')); // Set the fields as required. @@ -382,13 +382,13 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase { 'title[0][value]' => 'test required', 'files[field_paragraphs_0_subform_field_paragraphs_0_subform_field_image_only_0]' => drupal_realpath('temporary://myImage2.jpg'), ); - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $edit = [ 'field_paragraphs[0][subform][field_paragraphs][0][subform][field_image_only][0][width]' => 100, 'field_paragraphs[0][subform][field_paragraphs][0][subform][field_image_only][0][height]' => 100, 'field_paragraphs[0][subform][field_paragraphs][0][subform][field_image_only][0][alt]' => 'Alternative_text', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->assertText('test required has been created.'); $this->assertNoRaw('This value should not be null.'); @@ -430,7 +430,7 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase { $edit = array( 'title[0][value]' => 'Nested twins', ); - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish'), t('Save')); $this->assertText('Nested twins has been created.'); $this->assertNoText('This entity (paragraph: ) cannot be referenced.'); @@ -463,7 +463,7 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase { 'field_paragraphs[0][subform][field_entity_reference][0][target_id]' => $node->label() . ' (' . $node->id() . ')', 'title[0][value]' => 'choke test', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); // Delete the referenced node. $node->delete(); // Edit the node with the reference. @@ -494,7 +494,7 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase { $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_0_restore'); $node = $this->drupalGetNodeByTitle('Example publish/unpublish'); $edit = ['field_paragraphs[0][subform][field_entity_reference][0][target_id]' => $node->label() . ' (' . $node->id() . ')']; - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); $this->assertText('choke test has been updated.'); $this->assertLink('Example publish/unpublish'); // Delete the new referenced node. @@ -510,14 +510,14 @@ class ParagraphsAdministrationTest extends ParagraphsTestBase { $this->drupalPostAjaxForm('node/' . $node->id() . '/edit', [], 'field_paragraphs_0_edit'); // Try to save with an invalid reference. $edit = ['field_paragraphs[0][subform][field_entity_reference][0][target_id]' => 'foo']; - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); $this->assertText('There are no entities matching "foo".'); // Remove the Paragraph and save the node. $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_0_remove'); $elements = $this->xpath('//*[@name="field_paragraphs_0_confirm_remove"]'); $this->assertTrue(!empty($elements), "'Confirm removal' button appears."); $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_0_confirm_remove'); - $this->drupalPostFormSave(NULL, [], t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and keep published')); $this->assertText('choke test has been updated.'); // Verify that the text displayed is correct when no paragraph has been diff --git a/src/Tests/Classic/ParagraphsConfigTest.php b/src/Tests/Classic/ParagraphsConfigTest.php index 01ae4d5..54e765e 100644 --- a/src/Tests/Classic/ParagraphsConfigTest.php +++ b/src/Tests/Classic/ParagraphsConfigTest.php @@ -53,14 +53,14 @@ class ParagraphsConfigTest extends ParagraphsTestBase { // Create a node with a paragraph. $this->drupalPostAjaxForm('node/add/paragraphed_test', [], 'paragraphs_field_paragraph_type_test_add_more'); $edit = ['title[0][value]' => 'paragraphed_title']; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); // Attempt to add a translation. $node = $this->drupalGetNodeByTitle('paragraphed_title'); $this->drupalGet('node/' . $node->id() . '/translations'); $this->clickLink(t('Add')); // Save the translation. - $this->drupalPostFormSave(NULL, [], t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and keep published (this translation)')); $this->assertText('paragraphed_test paragraphed_title has been updated.'); } @@ -157,10 +157,10 @@ class ParagraphsConfigTest extends ParagraphsTestBase { $edit = [ 'title[0][value]' => 'test_title', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->assertText('paragraphs field is required.'); $this->drupalPostAjaxForm(NULL, [], 'paragraphs_paragraph_type_test_add_more'); - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->assertText('paragraphed_test test_title has been created.'); } diff --git a/src/Tests/Classic/ParagraphsCoreVersionUiTestTrait.php b/src/Tests/Classic/ParagraphsCoreVersionUiTestTrait.php index 17f27c1..361c872 100644 --- a/src/Tests/Classic/ParagraphsCoreVersionUiTestTrait.php +++ b/src/Tests/Classic/ParagraphsCoreVersionUiTestTrait.php @@ -8,26 +8,51 @@ namespace Drupal\paragraphs\Tests\Classic; trait ParagraphsCoreVersionUiTestTrait { /** - * Executes a form submission depending on the Drupal Core version. + * An adapter for 8.3 > 8.4 Save (and (un)publish) node button change. + * + * Arguments are the same as WebTestBase::drupalPostForm. + * + * @see \Drupal\simpletest\WebTestBase::drupalPostForm + * @see https://www.drupal.org/node/2847274 * * @param \Drupal\Core\Url|string $path - * The location of the post form. - * @param array|null $edit_d8_3 - * The field data values in Drupal 8.3.x. - * @param string $submit_d8_3 - * The submit button value in Drupal 8.3.x. - * @param string $submit_d8_4 - * The submit button value in Drupal 8.4.x. - * @param array|null $edit_d8_4 - * (optional) The field data values in Drupal 8.4.x. Defaults to 8.3.x. + * Location of the post form. + * @param array $edit + * Field data in an associative array. + * @param mixed $submit + * Value of the submit button whose click is to be emulated. For example, + * @param array $options + * (optional) Options to be forwarded to the url generator. + * @param array $headers + * (optional) An array containing additional HTTP request headers. + * @param string $form_html_id + * (optional) HTML ID of the form to be submitted. + * @param string $extra_post + * (optional) A string of additional data to append to the POST submission. */ - protected function drupalPostFormSave($path, $edit_d8_3, $submit_d8_3, $submit_d8_4, $edit_d8_4 = []) { - if (substr(\Drupal::VERSION, 0, 3) == '8.3') { - $this->drupalPostForm($path, $edit_d8_3, $submit_d8_3); - } - else { - $this->drupalPostForm($path, !empty($edit_d8_4) ? $edit_d8_4 : $edit_d8_3, $submit_d8_4); + protected function paragraphsPostNodeForm($path, $edit, $submit, array $options = [], array $headers = [], $form_html_id = NULL, $extra_post = NULL) { + $drupal_version = (float) substr(\Drupal::VERSION, 0, 3); + if ($drupal_version > 8.3) { + switch ($submit) { + case t('Save and unpublish'): + $submit = t('Save'); + $edit['status[value]'] = FALSE; + break; + + case t('Save and publish'): + $submit = t('Save'); + $edit['status[value]'] = TRUE; + break; + + case t('Save and keep published (this translation)'): + $submit = t('Save (this translation)'); + break; + + default: + $submit = t('Save'); + } } + parent::drupalPostForm($path, $edit, $submit, $options, $headers, $form_html_id, $extra_post); } } diff --git a/src/Tests/Classic/ParagraphsEditModesTest.php b/src/Tests/Classic/ParagraphsEditModesTest.php index 31e1c26..b6f52ff 100644 --- a/src/Tests/Classic/ParagraphsEditModesTest.php +++ b/src/Tests/Classic/ParagraphsEditModesTest.php @@ -58,7 +58,7 @@ class ParagraphsEditModesTest extends ParagraphsTestBase { 'files[field_paragraphs_0_subform_field_image_0]' => drupal_realpath('temporary://myImage1.jpg'), 'field_paragraphs[1][subform][field_title][0][value]' => 'Title example', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); // Assert the summary is correctly generated. $this->clickLink(t('Edit')); @@ -79,7 +79,7 @@ class ParagraphsEditModesTest extends ParagraphsTestBase { // Remove image. $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_0_edit'); $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_0_subform_field_image_0_remove_button'); - $this->drupalPostFormSave(NULL, [], t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and keep published')); // Assert the summary is correctly generated. $this->clickLink(t('Edit')); diff --git a/src/Tests/Classic/ParagraphsFieldGroupTest.php b/src/Tests/Classic/ParagraphsFieldGroupTest.php index 00ecf32..e3098cb 100644 --- a/src/Tests/Classic/ParagraphsFieldGroupTest.php +++ b/src/Tests/Classic/ParagraphsFieldGroupTest.php @@ -65,6 +65,6 @@ class ParagraphsFieldGroupTest extends ParagraphsTestBase { 'title[0][value]' => 'paragraphed_title', 'field_paragraphs[0][subform][field_text][0][value]' => 'paragraph_value', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); } } diff --git a/src/Tests/Classic/ParagraphsInlineEntityFormTest.php b/src/Tests/Classic/ParagraphsInlineEntityFormTest.php index e7b7a3f..41b8628 100644 --- a/src/Tests/Classic/ParagraphsInlineEntityFormTest.php +++ b/src/Tests/Classic/ParagraphsInlineEntityFormTest.php @@ -59,7 +59,7 @@ class ParagraphsInlineEntityFormTest extends ParagraphsTestBase { 'title[0][value]' => 'Dummy1', 'field_paragraphs[0][subform][field_article][0][inline_entity_form][title][0][value]' => 'Dummy2', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); // Go back into edit page. $node = $this->getNodeByTitle('Dummy1'); @@ -121,7 +121,7 @@ class ParagraphsInlineEntityFormTest extends ParagraphsTestBase { 'field_paragraphs[0][subform][field_article][0][inline_entity_form][title][0][value]' => 'Basic page 1', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); // Go back into edit page. $node = $this->getNodeByTitle('Article 1'); @@ -136,7 +136,7 @@ class ParagraphsInlineEntityFormTest extends ParagraphsTestBase { 'field_paragraphs[0][_weight]' => -1, 'field_paragraphs[1][_weight]' => -2, ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); } } diff --git a/src/Tests/Classic/ParagraphsPreviewTest.php b/src/Tests/Classic/ParagraphsPreviewTest.php index 3ab6798..6313d65 100644 --- a/src/Tests/Classic/ParagraphsPreviewTest.php +++ b/src/Tests/Classic/ParagraphsPreviewTest.php @@ -62,7 +62,7 @@ class ParagraphsPreviewTest extends ParagraphsTestBase { $paragraph_1 = $this->xpath('//*[@id="edit-field-paragraphs-0-subform-field-text-0-value"]')[0]; $this->assertEqual($paragraph_1['value'], $test_text_1); - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->clickLink('Edit'); $this->drupalPostAjaxForm(NULL, array(), 'field_paragraphs_text_add_more'); @@ -91,7 +91,7 @@ class ParagraphsPreviewTest extends ParagraphsTestBase { $paragraph_2 = $this->xpath('//*[@id="edit-field-paragraphs-1-subform-field-text-0-value"]')[0]; $this->assertEqual($paragraph_1['value'], $test_text_1); $this->assertEqual($paragraph_2['value'], $new_test_text_2); - $this->drupalPostFormSave(NULL, [], t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and keep published')); $this->assertRaw($test_text_1); $this->assertRaw($new_test_text_2); diff --git a/src/Tests/Classic/ParagraphsSummaryFormatterTest.php b/src/Tests/Classic/ParagraphsSummaryFormatterTest.php index aeb134e..ab6d8aa 100644 --- a/src/Tests/Classic/ParagraphsSummaryFormatterTest.php +++ b/src/Tests/Classic/ParagraphsSummaryFormatterTest.php @@ -57,13 +57,13 @@ class ParagraphsSummaryFormatterTest extends ParagraphsTestBase { 'field_paragraphs[0][subform][field_text][0][value]' => 'text_summary', 'field_paragraphs[1][subform][field_title][0][value]' => 'Title example', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->clickLink(t('Edit')); $this->drupalPostForm(NULL, [], t('Add user_paragraph')); $edit = [ 'field_paragraphs[2][subform][field_user][0][target_id]' => $this->admin_user->label() . ' (' . $this->admin_user->id() . ')', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); // Assert the summary is correctly generated. $this->assertText($this->admin_user->label()); diff --git a/src/Tests/Classic/ParagraphsTranslationTest.php b/src/Tests/Classic/ParagraphsTranslationTest.php index 5515db9..51b6544 100644 --- a/src/Tests/Classic/ParagraphsTranslationTest.php +++ b/src/Tests/Classic/ParagraphsTranslationTest.php @@ -100,7 +100,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { 'title[0][value]' => 'example_publish_unpublish', 'field_paragraphs_demo[0][subform][field_text_demo][0][value]' => 'Example published and unpublished', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->assertText(t('Example published and unpublished')); $this->clickLink(t('Edit')); @@ -110,7 +110,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { '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->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); $this->assertNoText(t('Example published and unpublished')); // Check the parent fields are set properly. Get the node. @@ -141,7 +141,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { ); // The button to remove a paragraph is present. $this->assertRaw(t('Remove')); - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $node = $this->drupalGetNodeByTitle('Title in english'); // The text is present when editing again. $this->clickLink(t('Edit')); @@ -163,7 +163,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { 'revision' => TRUE, 'revision_log[0][value]' => 'french 1', ); - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published (this translation)')); $this->assertText('Paragraphed article Title in french has been updated.'); // Check the english translation. @@ -188,7 +188,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { 'revision' => TRUE, 'revision_log[0][value]' => 'french 2', ); - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published (this translation)')); $this->assertText('Title Change in french'); $this->assertText('New text in french'); @@ -198,7 +198,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { $this->assertText('Title in english'); $this->assertText('Text in english'); // Save the original content on second request. - $this->drupalPostFormSave(NULL, NULL, t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and keep published (this translation)')); $this->assertText('Paragraphed article Title in english has been updated.'); // Test if reverting to old paragraphs revisions works, make sure that @@ -209,7 +209,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { $this->clickLink(t('Edit')); $this->assertRaw('Title in french'); $this->assertText('Text in french'); - $this->drupalPostFormSave(NULL, [], t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and keep published (this translation)')); $this->assertNoRaw('The content has either been modified by another user, or you have already submitted modifications'); $this->assertText('Text in french'); @@ -243,7 +243,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { 'field_paragraphs_demo[0][subform][field_images_demo][0][width]' => 100, 'field_paragraphs_demo[0][subform][field_images_demo][0][height]' => 100, ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); // Translate the node with the image paragraph. $this->clickLink('Translate'); @@ -253,7 +253,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { '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->drupalPostFormSave(NULL, $edit, t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published (this translation)')); $this->assertRaw('Title FR'); $this->drupalGet('node/add/paragraphed_content_demo'); @@ -263,7 +263,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { 'title[0][value]' => 'titulo', 'langcode[0][value]' => 'de', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $node = $this->drupalGetNodeByTitle('titulo'); $this->assertParagraphsLangcode($node->id(), 'de'); @@ -296,7 +296,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { 'field_paragraphs_demo' => [$paragraph_1, $translated_paragraph], ]); $this->drupalGet('node/' . $node->id() . '/edit'); - $this->drupalPostFormSave(NULL, [], t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and keep published')); $this->assertText('Paragraphed article ' . $node->label() . ' has been updated.'); // Check that first paragraph langcode has been updated. $paragraph = Paragraph::load($paragraph_1->id()); @@ -313,7 +313,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { '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->drupalPostFormSave('node/' . $node->id() . '/translations/add/de/en', $edit, t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm('node/' . $node->id() . '/translations/add/de/en', $edit, t('Save and keep published (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. @@ -328,7 +328,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { $this->drupalGet('node/add/paragraphed_content_demo'); $this->drupalPostForm(NULL, [], t('Add Nested Paragraph')); $edit = ['title[0][value]' => 'empty_node']; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); // Attempt to translate it. $this->clickLink(t('Translate')); $this->clickLink(t('Add')); @@ -410,7 +410,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { ]; $this->drupalPostForm(NULL, $edit, t('Upload')); $this->assertParagraphsButtons(1); - $this->drupalPostFormSave(NULL, NULL, t('Save and publish'), t('Save'), ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and publish')); $this->assertText('Title in english'); $node = $this->drupalGetNodeByTitle('Title in english'); // Check the paragraph langcode is 'en'. @@ -425,7 +425,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { $edit = [ 'title[0][value]' => 'Title in french', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published (this translation)')); $this->assertParagraphsLangcode($node->id(), 'en', 'fr'); $this->assertText('Paragraphed article Title in french has been updated.'); $this->assertText('Title in french'); @@ -443,7 +443,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { // check that the paragraphs buttons are still hidden. $this->assertParagraphsLangcode($node->id(), 'en', 'fr'); $this->assertNoParagraphsButtons(1); - $this->drupalPostFormSave(NULL, NULL, t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and keep published (this translation)')); $this->assertText('Title in french'); $this->assertNoText('Title in english'); @@ -478,7 +478,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { ], t('Upload')); $this->assertParagraphsLangcode($node->id()); $this->assertParagraphsButtons(2); - $this->drupalPostFormSave(NULL, NULL, t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and keep published (this translation)')); $this->assertText('Title in english (de)'); $this->assertNoText('Title in french'); // Check the original node and the paragraphs langcode are now 'de'. @@ -524,7 +524,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { // check that the paragraphs buttons are still hidden. $this->assertParagraphsLangcode($node->id(), 'de', 'fr'); $this->assertNoParagraphsButtons(2); - $this->drupalPostFormSave(NULL, NULL, t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and keep published (this translation)')); // Check the paragraphs langcode are still 'de' after saving the translation. $this->assertParagraphsLangcode($node->id(), 'de', 'fr'); $this->assertText('Title in french'); @@ -556,7 +556,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { ], t('Upload')); $this->assertParagraphsLangcode($node->id(), 'de'); $this->assertParagraphsButtons(3); - $this->drupalPostFormSave(NULL, NULL, t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and keep published (this translation)')); $this->assertText('Paragraphed article Title in english has been updated.'); // Check the original node and the paragraphs langcode are now 'en'. $this->assertParagraphsLangcode($node->id()); @@ -594,7 +594,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { 'files[field_paragraphs_demo_0_subform_field_paragraphs_demo_0_subform_field_images_demo_0][]' => $images->uri, ], t('Upload')); $this->assertParagraphsButtons(1); - $this->drupalPostFormSave(NULL, NULL, t('Save and publish'), t('Save'), ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and publish')); $this->assertText('Title in german'); $node1 = $this->getNodeByTitle('Title in german'); @@ -615,7 +615,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { // Check the paragraph langcode is still 'de' and its buttons are shown. $this->assertParagraphsLangcode($node1->id(), 'de'); $this->assertParagraphsButtons(1); - $this->drupalPostFormSave(NULL, NULL, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and keep published')); // Check the paragraph langcode is now 'en' after saving. $this->assertParagraphsLangcode($node1->id()); @@ -644,7 +644,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { ]; $this->drupalPostForm(NULL, $edit, t('Upload')); $this->assertParagraphsButtons(1); - $this->drupalPostFormSave(NULL, NULL, t('Save and publish'), t('Save'), ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and publish')); $this->assertText('Title in english'); $node2 = $this->drupalGetNodeByTitle('Title in english'); @@ -671,7 +671,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { ], t('Upload')); $this->assertParagraphsLangcode($node2->id()); $this->assertParagraphsButtons(2); - $this->drupalPostFormSave(NULL, NULL, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and keep published')); // Check the paragraphs langcode are now 'de' after saving. $this->assertParagraphsLangcode($node2->id(), 'de'); @@ -681,7 +681,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { 'title[0][value]' => 'Title in english', 'langcode[0][value]' => 'en', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); // Check the paragraphs langcode are now 'en' after saving. $this->assertParagraphsLangcode($node2->id()); @@ -711,7 +711,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { ], t('Upload')); $this->assertParagraphsLangcode($node2->id()); $this->assertParagraphsButtons(3); - $this->drupalPostFormSave(NULL, NULL, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and keep published')); // Check the paragraphs langcode are still 'en' after saving. $this->assertParagraphsLangcode($node2->id()); @@ -736,7 +736,7 @@ class ParagraphsTranslationTest extends ParagraphsTestBase { ], t('Upload')); $this->assertParagraphsLangcode($node2->id()); $this->assertParagraphsButtons(4); - $this->drupalPostFormSave(NULL, NULL, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and keep published')); // Check the paragraphs langcode are now 'de' after saving. $this->assertParagraphsLangcode($node2->id(), 'de'); } diff --git a/src/Tests/Classic/ParagraphsTypesTest.php b/src/Tests/Classic/ParagraphsTypesTest.php index 44ce8b5..62d3747 100644 --- a/src/Tests/Classic/ParagraphsTypesTest.php +++ b/src/Tests/Classic/ParagraphsTypesTest.php @@ -32,7 +32,7 @@ class ParagraphsTypesTest extends ParagraphsTestBase { $this->drupalGet('node/add/paragraphed_test'); $this->drupalPostAjaxForm(NULL, [], 'paragraphs_paragraph_type_test_add_more'); $edit = ['title[0][value]' => 'test_node']; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->assertText('paragraphed_test test_node has been created.'); // Attempt to delete the paragraph type already used. diff --git a/src/Tests/Classic/ParagraphsWidgetButtonsTest.php b/src/Tests/Classic/ParagraphsWidgetButtonsTest.php index c56ab97..a286e41 100644 --- a/src/Tests/Classic/ParagraphsWidgetButtonsTest.php +++ b/src/Tests/Classic/ParagraphsWidgetButtonsTest.php @@ -36,13 +36,13 @@ class ParagraphsWidgetButtonsTest extends ParagraphsTestBase { 'field_paragraphs[0][subform][field_text][0][value]' => $text, ]; $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_text_paragraph_add_more'); - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $node = $this->drupalGetNodeByTitle('paragraphs_mode_test'); // Test the 'Open' mode. $this->drupalGet('node/' . $node->id() . '/edit'); $this->assertFieldByName('field_paragraphs[0][subform][field_text][0][value]', $text); - $this->drupalPostFormSave(NULL, [], t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and keep published')); $this->assertText($text); // Test the 'Closed' mode. @@ -61,7 +61,7 @@ class ParagraphsWidgetButtonsTest extends ParagraphsTestBase { // Verify that we have warning message for each paragraph. $this->assertNoUniqueText('You have unsaved changes on this Paragraph item.'); $this->assertRaw('
' . $closed_mode_text); - $this->drupalPostFormSave(NULL, [], t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and keep published')); $this->assertText('paragraphed_test ' . $node->label() . ' has been updated.'); $this->assertText($closed_mode_text); @@ -77,7 +77,7 @@ class ParagraphsWidgetButtonsTest extends ParagraphsTestBase { $this->drupalPostAjaxForm(NULL, $edit, 'field_paragraphs_0_collapse'); $this->assertText('You have unsaved changes on this Paragraph item.'); $this->assertText($preview_mode_text); - $this->drupalPostFormSave(NULL, [], t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and keep published')); $this->assertText('paragraphed_test ' . $node->label() . ' has been updated.'); $this->assertText($preview_mode_text); @@ -92,7 +92,7 @@ class ParagraphsWidgetButtonsTest extends ParagraphsTestBase { $this->assertFieldByName('field_paragraphs[0][subform][field_text][0][value]', $preview_mode_text); $restore_text = 'restore_text'; $edit = ['field_paragraphs[0][subform][field_text][0][value]' => $restore_text]; - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); $this->assertText('paragraphed_test ' . $node->label() . ' has been updated.'); $this->assertText($restore_text); @@ -104,7 +104,7 @@ class ParagraphsWidgetButtonsTest extends ParagraphsTestBase { $this->assertText('Deleted Paragraph: text_paragraph'); // Click "Confirm Removal" button. $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_0_confirm_remove'); - $this->drupalPostFormSave(NULL, [], t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and keep published')); $this->assertText('paragraphed_test ' . $node->label() . ' has been updated.'); $this->assertNoText($restore_text); } diff --git a/src/Tests/Experimental/ParagraphsExperimentalAccessTest.php b/src/Tests/Experimental/ParagraphsExperimentalAccessTest.php index f1b2f78..f5c458f 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalAccessTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalAccessTest.php @@ -94,7 +94,7 @@ class ParagraphsExperimentalAccessTest extends ParagraphsExperimentalTestBase { $image_url = file_url_transform_relative($img1_url); $this->assertRaw($image_url, 'Image was found in preview'); $this->clickLink(t('Back to content editing')); - $this->drupalPostFormSave(NULL, [], 'Save and publish', 'Save', ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, [], t('Save and publish')); $node = $this->drupalGetNodeByTitle('Security test node'); @@ -129,14 +129,14 @@ class ParagraphsExperimentalAccessTest extends ParagraphsExperimentalTestBase { 'title[0][value]' => 'delete_permissions', 'field_paragraphs_demo[0][subform][field_text_demo][0][value]' => 'Test', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); // Edit the node. $this->clickLink(t('Edit')); // Check the remove button is present. $this->assertNotNull($this->xpath('//*[@name="field_paragraphs_demo_0_remove"]')); // Delete the Paragraph and save. $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_demo_0_remove'); - $this->drupalPostFormSave(NULL, [], t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and keep published')); $node = $this->getNodeByTitle('delete_permissions'); $this->assertUrl('node/' . $node->id()); } diff --git a/src/Tests/Experimental/ParagraphsExperimentalAddModesTest.php b/src/Tests/Experimental/ParagraphsExperimentalAddModesTest.php index 8d805c3..6c7f751 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalAddModesTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalAddModesTest.php @@ -189,7 +189,7 @@ class ParagraphsExperimentalAddModesTest extends ParagraphsExperimentalTestBase $this->setDefaultParagraphType('paragraphed_test', 'paragraphs', 'paragraphs_settings_edit', 'text_image'); $this->removeDefaultParagraphType('paragraphed_test'); $edit = ['title[0][value]' => 'New Host']; - $this->drupalPostFormSave(NULL, $edit, 'Save and publish', 'Save', $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->drupalGet('node/1/edit'); $this->assertText('No Paragraph added yet.'); } diff --git a/src/Tests/Experimental/ParagraphsExperimentalAdministrationTest.php b/src/Tests/Experimental/ParagraphsExperimentalAdministrationTest.php index 5b7006f..de86dc9 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalAdministrationTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalAdministrationTest.php @@ -74,7 +74,7 @@ class ParagraphsExperimentalAdministrationTest extends ParagraphsExperimentalTes 'field_paragraphs[0][subform][field_text][0][value]' => 'Test text 1', 'field_paragraphs[1][subform][field_text][0][value]' => 'Test text 2', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $node = $this->drupalGetNodeByTitle('TEST TITEL'); $paragraph1 = $node->field_paragraphs[0]->target_id; @@ -88,7 +88,7 @@ class ParagraphsExperimentalAdministrationTest extends ParagraphsExperimentalTes 'field_paragraphs[0][subform][field_text][0][value]' => 'Foo Bar 1', 'revision' => FALSE, ]; - $this->drupalPostFormSave('node/' . $node->id() . '/edit', $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); $this->countRevisions($node, $paragraph1, $paragraph2, 1); @@ -99,7 +99,7 @@ class ParagraphsExperimentalAdministrationTest extends ParagraphsExperimentalTes 'field_paragraphs[0][subform][field_text][0][value]' => 'Foo Bar 2', 'revision' => TRUE, ]; - $this->drupalPostFormSave('node/' . $node->id() . '/edit', $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); $this->countRevisions($node, $paragraph1, $paragraph2, 2); @@ -240,7 +240,7 @@ class ParagraphsExperimentalAdministrationTest extends ParagraphsExperimentalTes 'field_paragraphs[1][subform][field_text][0][value]' => 'Test text 2', 'files[field_paragraphs_1_subform_field_image_0]' => drupal_realpath('temporary://myImage2.jpg'), ); - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $node = $this->drupalGetNodeByTitle('Test article'); $img1_url = file_create_url(\Drupal::token()->replace('public://[date:custom:Y]-[date:custom:m]/myImage1.jpg')); @@ -328,7 +328,7 @@ class ParagraphsExperimentalAdministrationTest extends ParagraphsExperimentalTes 'field_paragraphs[0][subform][field_image][0][width]' => 300, 'field_paragraphs[0][subform][field_image][0][height]' => 300, ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); // Assert the paragraph is deleted after the user saves the node. $this->drupalGet('node/' . $node->id() . '/edit'); $this->assertNoRaw('myImage2.jpg'); @@ -353,13 +353,13 @@ class ParagraphsExperimentalAdministrationTest extends ParagraphsExperimentalTes 'title[0][value]' => 'Example publish/unpublish', 'field_paragraphs[0][subform][field_text][0][value]' => 'Example published and unpublished', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->assertText(t('Example published and unpublished')); $this->clickLink(t('Edit')); $edit = [ 'field_paragraphs[0][subform][status][value]' => FALSE, ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); $this->assertNoText(t('Example published and unpublished')); // Set the fields as required. @@ -385,13 +385,13 @@ class ParagraphsExperimentalAdministrationTest extends ParagraphsExperimentalTes 'title[0][value]' => 'test required', 'files[field_paragraphs_0_subform_field_paragraphs_0_subform_field_image_only_0]' => drupal_realpath('temporary://myImage2.jpg'), ); - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $edit = [ 'field_paragraphs[0][subform][field_paragraphs][0][subform][field_image_only][0][width]' => 100, 'field_paragraphs[0][subform][field_paragraphs][0][subform][field_image_only][0][height]' => 100, 'field_paragraphs[0][subform][field_paragraphs][0][subform][field_image_only][0][alt]' => 'Alternative_text', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->assertText('test required has been created.'); $this->assertNoRaw('This value should not be null.'); @@ -433,7 +433,7 @@ class ParagraphsExperimentalAdministrationTest extends ParagraphsExperimentalTes $edit = array( 'title[0][value]' => 'Nested twins', ); - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->assertText('Nested twins has been created.'); $this->assertNoText('This entity (paragraph: ) cannot be referenced.'); @@ -469,7 +469,7 @@ class ParagraphsExperimentalAdministrationTest extends ParagraphsExperimentalTes 'field_paragraphs[0][subform][field_entity_reference][0][target_id]' => $node->label() . ' (' . $node->id() . ')', 'title[0][value]' => 'choke test', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); // Delete the referenced node. $node->delete(); // Edit the node with the reference. @@ -495,7 +495,7 @@ class ParagraphsExperimentalAdministrationTest extends ParagraphsExperimentalTes // Fix the broken reference. $node = $this->drupalGetNodeByTitle('Example publish/unpublish'); $edit = ['field_paragraphs[0][subform][field_entity_reference][0][target_id]' => $node->label() . ' (' . $node->id() . ')']; - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); $this->assertText('choke test has been updated.'); $this->assertLink('Example publish/unpublish'); // Delete the new referenced node. @@ -517,11 +517,11 @@ class ParagraphsExperimentalAdministrationTest extends ParagraphsExperimentalTes $this->assertFieldByName('field_paragraphs[0][subform][field_entity_reference][1][target_id]'); // Try to save with and invalid reference. $edit = ['field_paragraphs[0][subform][field_entity_reference][0][target_id]' => 'foo']; - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); $this->assertText('There are no entities matching "foo".'); // Remove the Paragraph and save the node. $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_0_remove'); - $this->drupalPostFormSave(NULL, [], t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and publish')); $this->assertText('choke test has been updated.'); // Verify that the text displayed is correct when no paragraph has been diff --git a/src/Tests/Experimental/ParagraphsExperimentalBehaviorsTest.php b/src/Tests/Experimental/ParagraphsExperimentalBehaviorsTest.php index 307e152..d451a83 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalBehaviorsTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalBehaviorsTest.php @@ -100,7 +100,7 @@ class ParagraphsExperimentalBehaviorsTest extends ParagraphsExperimentalTestBase $behavior_xpath = $this->xpath("//div[@id = 'edit-field-paragraphs-0-top']/following-sibling::*[1][@id = 'edit-field-paragraphs-0-behavior-plugins-test-text-color']"); $this->assertNotEqual($behavior_xpath, FALSE, 'Behavior form position incorrect'); - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); // Asserting that the error message is shown. $this->assertText('The only allowed values are blue and red.'); // Updating the text color to an allowed value. @@ -108,7 +108,7 @@ class ParagraphsExperimentalBehaviorsTest extends ParagraphsExperimentalTestBase $edit = [ 'field_paragraphs[0][behavior_plugins][test_text_color][text_color]' => $plugin_text, ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); // Assert that the class has been added to the element. $this->assertRaw('class="red_plugin_text'); @@ -122,7 +122,7 @@ class ParagraphsExperimentalBehaviorsTest extends ParagraphsExperimentalTestBase 'field_paragraphs[0][behavior_plugins][test_text_color][text_color]' => $updated_text, 'field_paragraphs[0][behavior_plugins][test_bold_text][bold_text]' => TRUE, ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); $this->assertNoRaw('class="red_plugin_text'); $this->assertRaw('class="blue_plugin_text bold_plugin_text'); $this->clickLink('Edit'); @@ -140,7 +140,7 @@ class ParagraphsExperimentalBehaviorsTest extends ParagraphsExperimentalTestBase $this->assertNoFieldByName('field_paragraphs[0][behavior_plugins][test_text_color][text_color]', $updated_text); $this->assertNoFieldByName('field_paragraphs[0][behavior_plugins][test_bold_text][bold_text]', TRUE); - $this->drupalPostFormSave(NULL, [], t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and keep published')); // Make sure that values don't change if a user without the 'edit behavior // plugin settings' permission saves a node with paragraphs and enabled @@ -177,7 +177,7 @@ class ParagraphsExperimentalBehaviorsTest extends ParagraphsExperimentalTestBase 'title[0][value]' => 'paragraph with no fields', 'field_paragraphs[0][subform][field_text_test][0][value]' => 'my behavior plugin does not have any field', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->assertRaw('dummy_plugin_text'); // Tests behavior plugin on paragraph type with no fields. @@ -187,7 +187,7 @@ class ParagraphsExperimentalBehaviorsTest extends ParagraphsExperimentalTestBase $this->drupalGet('node/add/paragraphed_test'); $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_fieldless_add_more'); $edit = ['title[0][value]' => t('Fieldless')]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->assertResponse(200); } @@ -239,7 +239,7 @@ class ParagraphsExperimentalBehaviorsTest extends ParagraphsExperimentalTestBase 'field_paragraphs[1][subform][paragraphs][0][subform][field_text][0][value]' => 'nested_paragraph', 'field_paragraphs[1][behavior_plugins][test_bold_text][bold_text]' => TRUE, ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); // Assert that the summary includes the text of the behavior plugins. $this->clickLink('Edit'); @@ -251,7 +251,7 @@ class ParagraphsExperimentalBehaviorsTest extends ParagraphsExperimentalTestBase $edit = [ 'title[0][value]' => 'collapsed_test', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); // Check an empty nested paragraph summary. $this->clickLink('Edit'); @@ -305,7 +305,7 @@ class ParagraphsExperimentalBehaviorsTest extends ParagraphsExperimentalTestBase 'field_paragraphs[1][subform][field_text][0][value]' => 'first_paragraph', 'field_paragraphs[1][behavior_plugins][test_bold_text][bold_text]' => TRUE, ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->clickLink('Edit'); $edit = [ @@ -314,7 +314,7 @@ class ParagraphsExperimentalBehaviorsTest extends ParagraphsExperimentalTestBase 'field_paragraphs[1][behavior_plugins][test_text_color][text_color]' => 'red', 'field_paragraphs[1][_weight]' => 0, ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); $this->assertNoErrorsLogged(); $this->clickLink('Edit'); $this->assertFieldByName('field_paragraphs[0][behavior_plugins][test_text_color][text_color]', 'red'); diff --git a/src/Tests/Experimental/ParagraphsExperimentalConfigTest.php b/src/Tests/Experimental/ParagraphsExperimentalConfigTest.php index ed11c88..6cd074b 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalConfigTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalConfigTest.php @@ -54,14 +54,14 @@ class ParagraphsExperimentalConfigTest extends ParagraphsExperimentalTestBase { // Create a node with a paragraph. $this->drupalPostAjaxForm('node/add/paragraphed_test', [], 'field_paragraphs_paragraph_type_test_add_more'); $edit = ['title[0][value]' => 'paragraphed_title']; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); // Attempt to add a translation. $node = $this->drupalGetNodeByTitle('paragraphed_title'); $this->drupalGet('node/' . $node->id() . '/translations'); $this->clickLink(t('Add')); // Save the translation. - $this->drupalPostFormSave(NULL, [], t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and keep published (this translation)')); $this->assertText('paragraphed_test paragraphed_title has been updated.'); } @@ -183,7 +183,7 @@ class ParagraphsExperimentalConfigTest extends ParagraphsExperimentalTestBase { $edit = [ 'title[0][value]' => 'Testing included types' ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->assertText('paragraphed_test Testing included types has been created.'); // Include all types. @@ -202,7 +202,7 @@ class ParagraphsExperimentalConfigTest extends ParagraphsExperimentalTestBase { $edit = [ 'title[0][value]' => 'Testing all excluded types' ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->assertText('paragraphed_test Testing all excluded types has been created.'); } @@ -230,7 +230,7 @@ class ParagraphsExperimentalConfigTest extends ParagraphsExperimentalTestBase { $edit = [ 'title[0][value]' => 'Testing excluded types' ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->assertText('paragraphed_test Testing excluded types has been created.'); // Exclude all types. @@ -246,7 +246,7 @@ class ParagraphsExperimentalConfigTest extends ParagraphsExperimentalTestBase { $edit = [ 'title[0][value]' => 'Testing all excluded types' ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->assertText('paragraphed_test Testing all excluded types has been created.'); } } diff --git a/src/Tests/Experimental/ParagraphsExperimentalDuplicateFeatureTest.php b/src/Tests/Experimental/ParagraphsExperimentalDuplicateFeatureTest.php index b9d2dda..1c346f0 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalDuplicateFeatureTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalDuplicateFeatureTest.php @@ -43,7 +43,7 @@ class ParagraphsExperimentalDuplicateFeatureTest extends ParagraphsExperimentalT 'field_paragraphs[1][subform][field_text][0][value]' => 'B', 'field_paragraphs[2][subform][field_text][0][value]' => 'C', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $node = $this->drupalGetNodeByTitle('paragraphs_mode_test'); $this->drupalGet('node/' . $node->id() . '/edit'); @@ -69,7 +69,7 @@ class ParagraphsExperimentalDuplicateFeatureTest extends ParagraphsExperimentalT ]; // Save and check if all paragraphs are present in the correct order. - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); $this->drupalGet('node/' . $node->id() . '/edit'); $this->assertFieldByName('field_paragraphs[0][subform][field_text][0][value]', 'A'); $this->assertFieldByName('field_paragraphs[1][subform][field_text][0][value]', 'A'); @@ -79,7 +79,7 @@ class ParagraphsExperimentalDuplicateFeatureTest extends ParagraphsExperimentalT // Delete the second A, then duplicate C. $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_1_remove'); $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_2_duplicate'); - $this->drupalPostFormSave(NULL, [], t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and keep published')); $this->drupalGet('node/' . $node->id() . '/edit'); $this->assertFieldByName('field_paragraphs[0][subform][field_text][0][value]', 'A'); @@ -116,7 +116,7 @@ class ParagraphsExperimentalDuplicateFeatureTest extends ParagraphsExperimentalT $edit = [ 'title[0][value]' => 'paragraphs_mode_test', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $node = $this->drupalGetNodeByTitle('paragraphs_mode_test'); // Add a text field to nested paragraph. @@ -125,7 +125,7 @@ class ParagraphsExperimentalDuplicateFeatureTest extends ParagraphsExperimentalT $edit = [ 'field_paragraphs[0][subform][field_nested][0][subform][field_text][0][value]' => $text, ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); // Switch mode to closed. $this->setParagraphsWidgetMode('paragraphed_test', 'field_paragraphs', 'closed'); @@ -145,7 +145,7 @@ class ParagraphsExperimentalDuplicateFeatureTest extends ParagraphsExperimentalT // Save and check if the changed text paragraph value of the duplicated // paragraph is not the same as in the original paragraph. - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); $this->assertUniqueText($text); $this->assertUniqueText($second_paragraph_text); } diff --git a/src/Tests/Experimental/ParagraphsExperimentalEditModesTest.php b/src/Tests/Experimental/ParagraphsExperimentalEditModesTest.php index ca99a31..2a0615a 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalEditModesTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalEditModesTest.php @@ -63,13 +63,13 @@ class ParagraphsExperimentalEditModesTest extends ParagraphsExperimentalTestBase 'files[field_paragraphs_0_subform_field_image_0]' => drupal_realpath('temporary://myImage1.jpg'), 'field_paragraphs[1][subform][field_title][0][value]' => 'Title example', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->clickLink(t('Edit')); $this->drupalPostForm(NULL, [], t('Add user_paragraph')); $edit = [ 'field_paragraphs[2][subform][field_user][0][target_id]' => $this->admin_user->label() . ' (' . $this->admin_user->id() . ')', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); // Assert the summary is correctly generated. $this->clickLink(t('Edit')); @@ -91,7 +91,7 @@ class ParagraphsExperimentalEditModesTest extends ParagraphsExperimentalTestBase // Remove image. $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_0_edit'); $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_0_subform_field_image_0_remove_button'); - $this->drupalPostFormSave(NULL, [], t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and publish')); // Assert the summary is correctly generated. $this->clickLink(t('Edit')); @@ -111,7 +111,7 @@ class ParagraphsExperimentalEditModesTest extends ParagraphsExperimentalTestBase 'title[0][value]' => 'Node title', 'field_paragraphs[0][subform][field_nested_content][0][subform][field_user][0][target_id]' => $test_user->label() . ' (' . $test_user->id() . ')', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); // Create an orphaned ER field item by deleting the target entity. $test_user->delete(); diff --git a/src/Tests/Experimental/ParagraphsExperimentalFieldGroupTest.php b/src/Tests/Experimental/ParagraphsExperimentalFieldGroupTest.php index 7f702b4..8305ddc 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalFieldGroupTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalFieldGroupTest.php @@ -66,7 +66,7 @@ class ParagraphsExperimentalFieldGroupTest extends ParagraphsExperimentalTestBas 'title[0][value]' => 'paragraphed_title', 'field_paragraphs[0][subform][field_text][0][value]' => 'paragraph_value', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); } } diff --git a/src/Tests/Experimental/ParagraphsExperimentalHeaderActionsTest.php b/src/Tests/Experimental/ParagraphsExperimentalHeaderActionsTest.php index 599f698..bf03ef9 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalHeaderActionsTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalHeaderActionsTest.php @@ -62,7 +62,7 @@ class ParagraphsExperimentalHeaderActionsTest extends ParagraphsExperimentalTest $edit = [ 'title[0][value]' => 'Test', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->assertText('paragraphed_test Test has been created.'); $node = $this->getNodeByTitle('Test'); @@ -134,7 +134,7 @@ class ParagraphsExperimentalHeaderActionsTest extends ParagraphsExperimentalTest $edit = [ 'title[0][value]' => 'Test', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->assertText('paragraphed_test Test has been created.'); $node = $this->getNodeByTitle('Test'); @@ -211,7 +211,7 @@ class ParagraphsExperimentalHeaderActionsTest extends ParagraphsExperimentalTest $edit = [ 'title[0][value]' => 'Test', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->assertText('paragraphed_test Test has been created.'); $node = $this->getNodeByTitle('Test'); diff --git a/src/Tests/Experimental/ParagraphsExperimentalInlineEntityFormTest.php b/src/Tests/Experimental/ParagraphsExperimentalInlineEntityFormTest.php index ee4cd5f..73815d3 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalInlineEntityFormTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalInlineEntityFormTest.php @@ -68,7 +68,7 @@ class ParagraphsExperimentalInlineEntityFormTest extends ParagraphsExperimentalT 'title[0][value]' => 'Dummy1', 'field_paragraphs[0][subform][field_article][0][inline_entity_form][title][0][value]' => 'Dummy2', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); // Go back into edit page. $node = $this->getNodeByTitle('Dummy1'); @@ -129,7 +129,7 @@ class ParagraphsExperimentalInlineEntityFormTest extends ParagraphsExperimentalT 'field_paragraphs[0][subform][field_article][0][inline_entity_form][title][0][value]' => 'Basic page 1', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); // Go back into edit page. $node = $this->getNodeByTitle('Article 1'); @@ -142,7 +142,7 @@ class ParagraphsExperimentalInlineEntityFormTest extends ParagraphsExperimentalT $edit = [ 'field_paragraphs[1][subform][field_article][0][inline_entity_form][title][0][value]' => 'Basic 2' ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); } } diff --git a/src/Tests/Experimental/ParagraphsExperimentalPreviewTest.php b/src/Tests/Experimental/ParagraphsExperimentalPreviewTest.php index 393449c..f22fb28 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalPreviewTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalPreviewTest.php @@ -63,7 +63,7 @@ class ParagraphsExperimentalPreviewTest extends ParagraphsExperimentalTestBase { $paragraph_1 = $this->xpath('//*[@id="edit-field-paragraphs-0-subform-field-text-0-value"]')[0]; $this->assertEqual($paragraph_1['value'], $test_text_1); - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); $this->clickLink('Edit'); $this->drupalPostAjaxForm(NULL, array(), 'field_paragraphs_text_add_more'); @@ -92,7 +92,7 @@ class ParagraphsExperimentalPreviewTest extends ParagraphsExperimentalTestBase { $paragraph_2 = $this->xpath('//*[@id="edit-field-paragraphs-1-subform-field-text-0-value"]')[0]; $this->assertEqual($paragraph_1['value'], $test_text_1); $this->assertEqual($paragraph_2['value'], $new_test_text_2); - $this->drupalPostFormSave(NULL, [], t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and publish')); $this->assertRaw($test_text_1); $this->assertRaw($new_test_text_2); diff --git a/src/Tests/Experimental/ParagraphsExperimentalSummaryFormatterTest.php b/src/Tests/Experimental/ParagraphsExperimentalSummaryFormatterTest.php index ab79c0c..81215fb 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalSummaryFormatterTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalSummaryFormatterTest.php @@ -56,13 +56,13 @@ class ParagraphsExperimentalSummaryFormatterTest extends ParagraphsExperimentalT 'field_paragraphs[0][subform][field_text][0][value]' => 'text_summary', 'field_paragraphs[1][subform][field_title][0][value]' => 'Title example', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->clickLink(t('Edit')); $this->drupalPostForm(NULL, [], t('Add user_paragraph')); $edit = [ 'field_paragraphs[2][subform][field_user][0][target_id]' => $this->admin_user->label() . ' (' . $this->admin_user->id() . ')', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); // Assert the summary is correctly generated. $this->assertText($this->admin_user->label()); diff --git a/src/Tests/Experimental/ParagraphsExperimentalTranslationTest.php b/src/Tests/Experimental/ParagraphsExperimentalTranslationTest.php index dbfc707..bb5be9e 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalTranslationTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalTranslationTest.php @@ -96,7 +96,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa 'title[0][value]' => 'example_publish_unpublish', 'field_paragraphs_demo[0][subform][field_text_demo][0][value]' => 'Example published and unpublished', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->assertText(t('Example published and unpublished')); $this->clickLink(t('Edit')); @@ -106,7 +106,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa '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->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); $this->assertNoText(t('Example published and unpublished')); // Check the parent fields are set properly. Get the node. @@ -137,7 +137,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa ); // The button to remove a paragraph is present. $this->assertRaw(t('Remove')); - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $node = $this->drupalGetNodeByTitle('Title in english'); // The text is present when editing again. $this->clickLink(t('Edit')); @@ -159,7 +159,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa 'revision' => TRUE, 'revision_log[0][value]' => 'french 1', ); - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published (this translation)')); $this->assertText('Paragraphed article Title in french has been updated.'); // Check the english translation. @@ -184,7 +184,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa 'revision' => TRUE, 'revision_log[0][value]' => 'french 2', ); - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published (this translation)')); $this->assertText('Title Change in french'); $this->assertText('New text in french'); @@ -194,7 +194,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa $this->assertText('Title in english'); $this->assertText('Text in english'); // Save the original content on second request. - $this->drupalPostFormSave(NULL, NULL, t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and keep published (this translation)')); $this->assertText('Paragraphed article Title in english has been updated.'); // Test if reverting to old paragraphs revisions works, make sure that @@ -205,7 +205,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa $this->clickLink(t('Edit')); $this->assertRaw('Title in french'); $this->assertText('Text in french'); - $this->drupalPostFormSave(NULL, [], t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and keep published (this translation)')); $this->assertNoRaw('The content has either been modified by another user, or you have already submitted modifications'); $this->assertText('Text in french'); @@ -239,7 +239,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa 'field_paragraphs_demo[0][subform][field_images_demo][0][width]' => 100, 'field_paragraphs_demo[0][subform][field_images_demo][0][height]' => 100, ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); // Translate the node with the image paragraph. $this->clickLink('Translate'); @@ -249,7 +249,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa '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->drupalPostFormSave(NULL, $edit, t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published (this translation)')); $this->assertRaw('Title FR'); $this->drupalGet('node/add/paragraphed_content_demo'); @@ -259,7 +259,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa 'title[0][value]' => 'titulo', 'langcode[0][value]' => 'de', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $node = $this->drupalGetNodeByTitle('titulo'); $this->assertParagraphsLangcode($node->id(), 'de'); @@ -292,7 +292,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa 'field_paragraphs_demo' => [$paragraph_1, $translated_paragraph], ]); $this->drupalGet('node/' . $node->id() . '/edit'); - $this->drupalPostFormSave(NULL, [], t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and keep published')); $this->assertText('Paragraphed article ' . $node->label() . ' has been updated.'); // Check that first paragraph langcode has been updated. $paragraph = Paragraph::load($paragraph_1->id()); @@ -309,7 +309,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa '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->drupalPostFormSave('node/' . $node->id() . '/translations/add/de/en', $edit, t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm('node/' . $node->id() . '/translations/add/de/en', $edit, t('Save and keep published (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. @@ -324,7 +324,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa $this->drupalGet('node/add/paragraphed_content_demo'); $this->drupalPostForm(NULL, [], t('Add Nested Paragraph')); $edit = ['title[0][value]' => 'empty_node']; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); // Attempt to translate it. $this->clickLink(t('Translate')); $this->clickLink(t('Add')); @@ -418,7 +418,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa ]; $this->drupalPostForm(NULL, $edit, t('Upload')); $this->assertParagraphsButtons(1); - $this->drupalPostFormSave(NULL, NULL, t('Save and publish'), t('Save'), ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and publish')); $this->assertText('Title in english'); $node = $this->drupalGetNodeByTitle('Title in english'); // Check the paragraph langcode is 'en'. @@ -433,7 +433,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa $edit = [ 'title[0][value]' => 'Title in french', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published (this translation)')); $this->assertParagraphsLangcode($node->id(), 'en', 'fr'); $this->assertText('Paragraphed article Title in french has been updated.'); $this->assertText('Title in french'); @@ -451,7 +451,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa // check that the paragraphs buttons are still hidden. $this->assertParagraphsLangcode($node->id(), 'en', 'fr'); $this->assertNoParagraphsButtons(1); - $this->drupalPostFormSave(NULL, NULL, t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and keep published (this translation)')); $this->assertText('Title in french'); $this->assertNoText('Title in english'); @@ -486,7 +486,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa ], t('Upload')); $this->assertParagraphsLangcode($node->id()); $this->assertParagraphsButtons(2); - $this->drupalPostFormSave(NULL, NULL, t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and keep published (this translation)')); $this->assertText('Title in english (de)'); $this->assertNoText('Title in french'); // Check the original node and the paragraphs langcode are now 'de'. @@ -532,7 +532,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa // check that the paragraphs buttons are still hidden. $this->assertParagraphsLangcode($node->id(), 'de', 'fr'); $this->assertNoParagraphsButtons(2); - $this->drupalPostFormSave(NULL, NULL, t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and keep published (this translation)')); // Check the paragraphs langcode are still 'de' after saving the translation. $this->assertParagraphsLangcode($node->id(), 'de', 'fr'); $this->assertText('Title in french'); @@ -564,7 +564,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa ], t('Upload')); $this->assertParagraphsLangcode($node->id(), 'de'); $this->assertParagraphsButtons(3); - $this->drupalPostFormSave(NULL, NULL, t('Save and keep published (this translation)'), t('Save (this translation)')); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and keep published (this translation)')); // Check the original node and the paragraphs langcode are now 'en'. $this->assertParagraphsLangcode($node->id()); } @@ -612,7 +612,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa 'files[field_paragraphs_demo_0_subform_field_paragraphs_demo_0_subform_field_images_demo_0][]' => $images->uri, ], t('Upload')); $this->assertParagraphsButtons(1); - $this->drupalPostFormSave(NULL, NULL, t('Save and publish'), t('Save'), ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and publish')); $this->assertText('Title in german'); $node1 = $this->getNodeByTitle('Title in german'); @@ -633,7 +633,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa // Check the paragraph langcode is still 'de' and its buttons are shown. $this->assertParagraphsLangcode($node1->id(), 'de'); $this->assertParagraphsButtons(1); - $this->drupalPostFormSave(NULL, NULL, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and keep published')); // Check the paragraph langcode is now 'en' after saving. $this->assertParagraphsLangcode($node1->id()); @@ -662,7 +662,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa ]; $this->drupalPostForm(NULL, $edit, t('Upload')); $this->assertParagraphsButtons(1); - $this->drupalPostFormSave(NULL, NULL, t('Save and publish'), t('Save'), ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and publish')); $this->assertText('Title in english'); $node2 = $this->drupalGetNodeByTitle('Title in english'); @@ -689,7 +689,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa ], t('Upload')); $this->assertParagraphsLangcode($node2->id()); $this->assertParagraphsButtons(2); - $this->drupalPostFormSave(NULL, NULL, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and keep published')); // Check the paragraphs langcode are now 'de' after saving. $this->assertParagraphsLangcode($node2->id(), 'de'); @@ -699,7 +699,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa 'title[0][value]' => 'Title in english', 'langcode[0][value]' => 'en', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and keep published')); // Check the paragraphs langcode are now 'en' after saving. $this->assertParagraphsLangcode($node2->id()); @@ -729,7 +729,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa ], t('Upload')); $this->assertParagraphsLangcode($node2->id()); $this->assertParagraphsButtons(3); - $this->drupalPostFormSave(NULL, NULL, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and keep published')); // Check the paragraphs langcode are still 'en' after saving. $this->assertParagraphsLangcode($node2->id()); @@ -754,7 +754,7 @@ class ParagraphsExperimentalTranslationTest extends ParagraphsExperimentalTestBa ], t('Upload')); $this->assertParagraphsLangcode($node2->id()); $this->assertParagraphsButtons(4); - $this->drupalPostFormSave(NULL, NULL, t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, NULL, t('Save and keep published')); // Check the paragraphs langcode are now 'de' after saving. $this->assertParagraphsLangcode($node2->id(), 'de'); } diff --git a/src/Tests/Experimental/ParagraphsExperimentalTypesTest.php b/src/Tests/Experimental/ParagraphsExperimentalTypesTest.php index 0ccd1f3..94d77f5 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalTypesTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalTypesTest.php @@ -30,7 +30,7 @@ class ParagraphsExperimentalTypesTest extends ParagraphsExperimentalTestBase { $this->drupalGet('node/add/paragraphed_test'); $this->drupalPostAjaxForm(NULL, [], 'paragraphs_paragraph_type_test_add_more'); $edit = ['title[0][value]' => 'test_node']; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $this->assertText('paragraphed_test test_node has been created.'); // Attempt to delete the paragraph type already used. diff --git a/src/Tests/Experimental/ParagraphsExperimentalWidgetButtonsTest.php b/src/Tests/Experimental/ParagraphsExperimentalWidgetButtonsTest.php index a1b2ce9..7433be6 100644 --- a/src/Tests/Experimental/ParagraphsExperimentalWidgetButtonsTest.php +++ b/src/Tests/Experimental/ParagraphsExperimentalWidgetButtonsTest.php @@ -51,13 +51,13 @@ class ParagraphsExperimentalWidgetButtonsTest extends ParagraphsExperimentalTest 'field_paragraphs[0][subform][field_text][0][value]' => $text, ]; $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_text_paragraph_add_more'); - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $node = $this->drupalGetNodeByTitle('paragraphs_mode_test'); // Test the 'Open' edit mode. $this->drupalGet('node/' . $node->id() . '/edit'); $this->assertFieldByName('field_paragraphs[0][subform][field_text][0][value]', $text); - $this->drupalPostFormSave(NULL, [], t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and keep published')); $this->assertText($text); // Test the 'Closed' edit mode. @@ -76,7 +76,7 @@ class ParagraphsExperimentalWidgetButtonsTest extends ParagraphsExperimentalTest // Verify that we have warning message for each paragraph. $this->assertNoUniqueText('You have unsaved changes on this Paragraph item.'); $this->assertRaw('
' . $closed_mode_text); - $this->drupalPostFormSave(NULL, [], t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and publish')); $this->assertText('paragraphed_test ' . $node->label() . ' has been updated.'); $this->assertText($closed_mode_text); @@ -92,7 +92,7 @@ class ParagraphsExperimentalWidgetButtonsTest extends ParagraphsExperimentalTest $this->drupalPostAjaxForm(NULL, $edit, 'field_paragraphs_0_collapse'); $this->assertText('You have unsaved changes on this Paragraph item.'); $this->assertText($preview_mode_text); - $this->drupalPostFormSave(NULL, [], t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and keep published')); $this->assertText('paragraphed_test ' . $node->label() . ' has been updated.'); $this->assertText($preview_mode_text); @@ -100,7 +100,7 @@ class ParagraphsExperimentalWidgetButtonsTest extends ParagraphsExperimentalTest $this->drupalGet('node/' . $node->id() . '/edit'); // Click "Remove" button. $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_0_remove'); - $this->drupalPostFormSave(NULL, [], t('Save and keep published'), t('Save')); + $this->paragraphsPostNodeForm(NULL, [], t('Save and publish')); $this->assertText('paragraphed_test ' . $node->label() . ' has been updated.'); $this->assertNoText($preview_mode_text); } @@ -132,7 +132,7 @@ class ParagraphsExperimentalWidgetButtonsTest extends ParagraphsExperimentalTest 'field_paragraphs[0][subform][field_text][0][value]' => $text, ]; $this->drupalPostAjaxForm(NULL, [], 'field_paragraphs_text_paragraph_add_more'); - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); $node = $this->drupalGetNodeByTitle('paragraphs_mode_test'); // Checking visible buttons on "Open" mode. diff --git a/tests/src/FunctionalJavascript/ParagraphsExperimentalAddWidgetTest.php b/tests/src/FunctionalJavascript/ParagraphsExperimentalAddWidgetTest.php index 2e27d15..3fe356e 100644 --- a/tests/src/FunctionalJavascript/ParagraphsExperimentalAddWidgetTest.php +++ b/tests/src/FunctionalJavascript/ParagraphsExperimentalAddWidgetTest.php @@ -143,7 +143,7 @@ class ParagraphsExperimentalAddWidgetTest extends JavascriptTestBase { $edit = [ 'title[0][value]' => 'Example title', ]; - $this->drupalPostFormSave(NULL, $edit, t('Save and publish'), t('Save'), $edit + ['status[value]' => TRUE]); + $this->paragraphsPostNodeForm(NULL, $edit, t('Save and publish')); // Check the created paragraphed test.