From 566cca8e5cc3e35aaf8ea312290820fecbaa8589 Mon Sep 17 00:00:00 2001
From: victoria-marina <victoria-marina@3702485.no-reply.drupal.org>
Date: Fri, 1 Apr 2022 17:15:35 +0000
Subject: [PATCH] Issue #3272770: Replace deprecated drupalPostForm() with
 submitForm()

---
 .../Functional/FillPdfFormDeleteFormTest.php  |  4 ++--
 .../FillPdfFormDuplicateFormTest.php          |  4 ++--
 tests/src/Functional/FillPdfFormFormTest.php  | 18 +++++++++++-------
 .../Functional/FillPdfFormImportFormTest.php  | 11 +++++++----
 .../Functional/FillPdfOverviewFormTest.php    |  7 ++++---
 .../Functional/FillPdfSettingsFormTest.php    | 19 +++++++++++--------
 .../src/Functional/FillPdfUploadTestBase.php  |  6 +++---
 .../Functional/HandlePdfControllerTest.php    | 13 ++++++++-----
 .../Functional/PdfWebformPopulationTest.php   |  3 ++-
 tests/src/Functional/UninstallTest.php        |  7 ++++---
 tests/src/Traits/TestFillPdfTrait.php         |  9 ++++++---
 11 files changed, 60 insertions(+), 41 deletions(-)

diff --git a/tests/src/Functional/FillPdfFormDeleteFormTest.php b/tests/src/Functional/FillPdfFormDeleteFormTest.php
index bf43fe8..a7cf7e5 100644
--- a/tests/src/Functional/FillPdfFormDeleteFormTest.php
+++ b/tests/src/Functional/FillPdfFormDeleteFormTest.php
@@ -46,7 +46,7 @@ class FillPdfFormDeleteFormTest extends BrowserTestBase {
     // We're now on the edit form. Add an admin title.
     $this->assertSession()->pageTextContains('New FillPDF form has been created.');
     $admin_title = 'Test';
-    $this->drupalPostForm(NULL, ['admin_title[0][value]' => $admin_title], 'Save');
+    $this->submitForm(['admin_title[0][value]' => $admin_title], 'Save');
     $this->assertSession()->pageTextContains("FillPDF Form $admin_title has been updated.");
 
     // Now click 'Delete' but come back clicking 'Cancel'.
@@ -88,7 +88,7 @@ class FillPdfFormDeleteFormTest extends BrowserTestBase {
 
     // We're on the edit form. Click 'Delete' and confirm deletion.
     $this->clickLink('Delete');
-    $this->drupalPostForm(NULL, NULL, 'Delete');
+    $this->submitForm([], 'Delete');
     $this->assertSession()->pageTextContains('FillPDF form deleted.');
     $this->assertSession()->addressEquals(Url::fromRoute('fillpdf.forms_admin'));
 
diff --git a/tests/src/Functional/FillPdfFormDuplicateFormTest.php b/tests/src/Functional/FillPdfFormDuplicateFormTest.php
index 9d072f9..4fa64b7 100644
--- a/tests/src/Functional/FillPdfFormDuplicateFormTest.php
+++ b/tests/src/Functional/FillPdfFormDuplicateFormTest.php
@@ -51,7 +51,7 @@ class FillPdfFormDuplicateFormTest extends BrowserTestBase {
     // We're now on the edit form. Add an admin title.
     $this->assertSession()->pageTextContains('New FillPDF form has been created.');
     $admin_title = 'Test';
-    $this->drupalPostForm(NULL, ['admin_title[0][value]' => $admin_title], 'Save');
+    $this->submitForm(['admin_title[0][value]' => $admin_title], 'Save');
     $this->assertSession()->pageTextContains("FillPDF Form $admin_title has been updated.");
 
     // Go to the overview form, click duplicate but cancel to come back.
@@ -65,7 +65,7 @@ class FillPdfFormDuplicateFormTest extends BrowserTestBase {
 
     // Back to the overview form, try again, and this time create a duplicate.
     $this->clickLink('Duplicate');
-    $this->drupalPostForm(NULL, ['new_admin_title' => 'Another test'], 'Save');
+    $this->submitForm(['new_admin_title' => 'Another test'], 'Save');
     $this->assertSession()->pageTextContains('FillPDF form has been duplicated.');
     $this->assertSession()->addressEquals(Url::fromRoute('fillpdf.forms_admin'));
 
diff --git a/tests/src/Functional/FillPdfFormFormTest.php b/tests/src/Functional/FillPdfFormFormTest.php
index e33752f..b9f4dee 100644
--- a/tests/src/Functional/FillPdfFormFormTest.php
+++ b/tests/src/Functional/FillPdfFormFormTest.php
@@ -50,7 +50,7 @@ class FillPdfFormFormTest extends FillPdfUploadTestBase {
 
     foreach ($testcases as $type => [$count, $id, $label]) {
       // Set a default entity type and check if it's properly saved.
-      $this->drupalPostForm(NULL, ['default_entity_type' => $type], self::OP_SAVE);
+      $this->submitForm(['default_entity_type' => $type], self::OP_SAVE);
       $this->assertSession()->pageTextContains("FillPDF Form has been updated.");
       $this->assertSession()->fieldValueEquals('default_entity_type', $type);
 
@@ -69,13 +69,14 @@ class FillPdfFormFormTest extends FillPdfUploadTestBase {
         $this->assertSession()->pageTextContains("Choose a $type to test populating the PDF template.");
         // Now enter an entity title.
         $this->assertSession()->optionExists('default_entity_id', $id);
-        $this->drupalPostForm(NULL, ['default_entity_id' => $id], self::OP_SAVE);
+        $this->submitForm(['default_entity_id' => $id], self::OP_SAVE);
         $expected_value = $id;
       }
       else {
         $this->assertSession()->pageTextContains("Enter the title of a $type to test populating the PDF template.");
         // Now choose an entity and check the entity type is unchanged.
-        $this->drupalPostForm(NULL, ['default_entity_id' => $label], self::OP_SAVE);
+        $this->submitForm(
+          ['default_entity_id' => $label], self::OP_SAVE);
         $expected_value = "$label ($id)";
       }
 
@@ -140,7 +141,8 @@ class FillPdfFormFormTest extends FillPdfUploadTestBase {
     $this->assertEquals($previous_file_id, $this->getLastFileId(), 'Generated file is not stored.');
 
     // Set the 'public' scheme and see if the 'destination_path' field appears.
-    $this->drupalPostForm($edit_form_url, ['scheme' => 'public'], self::OP_SAVE);
+    $this->drupalGet($edit_form_url);
+    $this->submitForm(['scheme' => 'public'], self::OP_SAVE);
     $this->assertSession()->fieldValueEquals('scheme', 'public');
     $this->assertSession()->pageTextContains('Destination path');
 
@@ -167,7 +169,8 @@ class FillPdfFormFormTest extends FillPdfUploadTestBase {
     $this->assertEquals($previous_file_id, $this->getLastFileId(), 'Generated file is not stored.');
 
     // Set the 'private' scheme.
-    $this->drupalPostForm($edit_form_url, ['scheme' => 'private'], self::OP_SAVE);
+    $this->drupalGet($edit_form_url);
+    $this->submitForm(['scheme' => 'private'], self::OP_SAVE);
     $this->assertSession()->fieldValueEquals('scheme', 'private');
 
     // Hit the generation route again and make sure this time the PDF file is
@@ -197,7 +200,7 @@ class FillPdfFormFormTest extends FillPdfUploadTestBase {
 
     // Set the administrative title and check if it has been successfully set.
     $admin_title = 'Example form';
-    $this->drupalPostForm(NULL, ['admin_title[0][value]' => $admin_title], self::OP_SAVE);
+    $this->submitForm(['admin_title[0][value]' => $admin_title], self::OP_SAVE);
     $this->assertSession()->pageTextContains("FillPDF Form $admin_title has been updated.");
     $this->assertSession()->fieldValueEquals('edit-admin-title-0-value', $admin_title);
 
@@ -210,7 +213,8 @@ class FillPdfFormFormTest extends FillPdfUploadTestBase {
     // managed_file.
     $fillpdf_form = FillPdfForm::load($this->getLatestFillPdfForm());
     $file_id = $fillpdf_form->get('file')->first()->getValue()['target_id'];
-    $this->drupalPostForm('admin/content/files', ['edit-filename' => 'fillpdf_test_v3.pdf'], 'Filter');
+    $this->drupalGet('admin/content/files');
+    $this->submitForm(['edit-filename' => 'fillpdf_test_v3.pdf'], 'Filter');
     $this->assertSession()->elementsCount('css', 'table td.views-field.views-field-filename', 1);
     $this->assertSession()->pageTextContains('Permanent');
     $file_url = File::load($file_id)->createFileUrl();
diff --git a/tests/src/Functional/FillPdfFormImportFormTest.php b/tests/src/Functional/FillPdfFormImportFormTest.php
index 83b036e..e3e30bb 100644
--- a/tests/src/Functional/FillPdfFormImportFormTest.php
+++ b/tests/src/Functional/FillPdfFormImportFormTest.php
@@ -47,7 +47,7 @@ class FillPdfFormImportFormTest extends BrowserTestBase {
       'admin_title[0][value]' => 'Test',
       'replacements[0][value]' => 'y|Yes',
     ];
-    $this->drupalPostForm(NULL, $edit, 'Save');
+    $this->submitForm($edit, 'Save');
     $this->assertSession()->pageTextContains("FillPDF Form Test has been updated.");
 
     // Export.
@@ -56,7 +56,8 @@ class FillPdfFormImportFormTest extends BrowserTestBase {
 
     // Duplicate the form.
     $duplicate_url = Url::fromRoute('entity.fillpdf_form.duplicate_form', ['fillpdf_form' => $form1_id]);
-    $this->drupalPostForm($duplicate_url, [], 'Save');
+    $this->drupalGet($duplicate_url);
+    $this->submitForm([], 'Save');
     $form2_id = $this->getLatestFillPdfForm();
 
     // Change some configuration.
@@ -65,12 +66,14 @@ class FillPdfFormImportFormTest extends BrowserTestBase {
     $edit = [
       'replacements[0][value]' => 'n|No',
     ];
-    $this->drupalPostForm(Url::fromRoute('entity.fillpdf_form.edit_form', ['fillpdf_form' => $form2_id]), $edit, 'Save');
+    $this->drupalGet(Url::fromRoute('entity.fillpdf_form.edit_form', ['fillpdf_form' => $form2_id]));
+    $this->submitForm($edit, 'Save');
     $this->assertSession()->pageTextContains("FillPDF Form Duplicate of Test has been updated.");
 
     // Import again.
     $import_url = Url::fromRoute('entity.fillpdf_form.import_form', ['fillpdf_form' => $form2_id]);
-    $this->drupalPostForm($import_url, ['code' => $code], 'Import');
+    $this->drupalGet($import_url);
+    $this->submitForm(['code' => $code], 'Import');
     // Check none of the mappings failed.
     $this->assertSession()->pageTextContains('Successfully imported FillPDF form configuration and matching PDF field keys.');
     $this->assertSession()->pageTextNotContains('but it does not exist on this form. Therefore, it was ignored.');
diff --git a/tests/src/Functional/FillPdfOverviewFormTest.php b/tests/src/Functional/FillPdfOverviewFormTest.php
index 5281775..570ff6a 100644
--- a/tests/src/Functional/FillPdfOverviewFormTest.php
+++ b/tests/src/Functional/FillPdfOverviewFormTest.php
@@ -50,7 +50,7 @@ class FillPdfOverviewFormTest extends FillPdfUploadTestBase {
 
     // Set the administrative title and check if it has been successfully set.
     $admin_title = 'Example form';
-    $this->drupalPostForm(NULL, ['admin_title[0][value]' => $admin_title], self::OP_SAVE);
+    $this->submitForm(['admin_title[0][value]' => $admin_title], self::OP_SAVE);
     $this->assertSession()->pageTextContains("FillPDF Form $admin_title has been updated.");
     $this->assertSession()->fieldValueEquals('edit-admin-title-0-value', $admin_title);
 
@@ -81,7 +81,8 @@ class FillPdfOverviewFormTest extends FillPdfUploadTestBase {
 
     // Set the administrative title.
     $admin_title = 'Example form';
-    $this->drupalPostForm("admin/structure/fillpdf/{$fid}", ['admin_title[0][value]' => $admin_title], self::OP_SAVE);
+    $this->drupalGet("admin/structure/fillpdf/{$fid}");
+    $this->submitForm(['admin_title[0][value]' => $admin_title], self::OP_SAVE);
     $this->assertSession()->statusCodeEquals(200);
 
     // Create host content type.
@@ -121,7 +122,7 @@ class FillPdfOverviewFormTest extends FillPdfUploadTestBase {
       'title[0][value]' => 'Test node',
       'field_fillpdf_form' => $fid,
     ];
-    $this->drupalPostForm(NULL, $edit, 'Save');
+    $this->submitForm($edit, 'Save');
     $fillpdf_form = FillPdfForm::load($fid);
     $this->assertSession()->linkByHrefExists($fillpdf_form->toUrl()->toString());
 
diff --git a/tests/src/Functional/FillPdfSettingsFormTest.php b/tests/src/Functional/FillPdfSettingsFormTest.php
index 29cb7cf..990b44f 100644
--- a/tests/src/Functional/FillPdfSettingsFormTest.php
+++ b/tests/src/Functional/FillPdfSettingsFormTest.php
@@ -92,7 +92,8 @@ class FillPdfSettingsFormTest extends BrowserTestBase {
     $this->configureFillPdf();
 
     // Now on the settings form, switch to the 'private' scheme.
-    $this->drupalPostForm(Url::fromRoute('fillpdf.settings'), ['template_scheme' => 'private'], 'Save configuration');
+    $this->drupalGet(Url::fromRoute('fillpdf.settings'));
+    $this->submitForm(['template_scheme' => 'private'], 'Save configuration');
 
     // Verify the new values have been submitted *and* successfully saved.
     $this->assertSession()->pageTextContains('The configuration options have been saved.');
@@ -142,7 +143,7 @@ class FillPdfSettingsFormTest extends BrowserTestBase {
 
     // Now on the settings form, save the unchanged configuration to create the
     // subdirectory. Verify it does exist now and is writeable.
-    $this->drupalPostForm(NULL, [], 'Save configuration');
+    $this->submitForm([], 'Save configuration');
     $this->assertSession()->pageTextContains('The configuration options have been saved.');
     $this->assertTrue(is_dir($directory), 'Directory exists now.');
     $this->assertTrue(\Drupal::service('file_system')->prepareDirectory($directory), 'Directory is writeable.');
@@ -154,7 +155,7 @@ class FillPdfSettingsFormTest extends BrowserTestBase {
     $file_system = $this->container->get('file_system');
     $file_system->rmdir($directory);
     \Drupal::service('file_system')->copy('public://.htaccess', $directory);
-    $this->drupalPostForm(NULL, [], 'Save configuration');
+    $this->submitForm([], 'Save configuration');
     $this->assertSession()->pageTextNotContains('The configuration options have been saved.');
     $this->assertSession()->pageTextContains('Could not automatically create the subdirectory');
   }
@@ -165,7 +166,8 @@ class FillPdfSettingsFormTest extends BrowserTestBase {
   public function testBackendFillPdfService() {
     // FillPDF is not yet configured. The settings form is however initialized
     // with the 'fillpdf_service' backend. Save that configuration.
-    $this->drupalPostForm(Url::fromRoute('fillpdf.settings'), NULL, 'Save configuration');
+    $this->drupalGet(Url::fromRoute('fillpdf.settings'));
+    $this->submitForm([], 'Save configuration');
 
     // There's currently no validation, so the 'backend' setting should be
     // both submitted and stored.
@@ -174,7 +176,7 @@ class FillPdfSettingsFormTest extends BrowserTestBase {
     $this->assertEquals($this->config('fillpdf.settings')->get('backend'), 'fillpdf_service');
 
     // Now add an API key and save again.
-    $this->drupalPostForm(NULL, ['fillpdf_service_api_key' => 'Invalid, just playing around.'], 'Save configuration');
+    $this->submitForm(['fillpdf_service_api_key' => 'Invalid, just playing around.'], 'Save configuration');
 
     // There's currently no validation, so the obviously invalid
     // 'fillpdf_service_api_key' should be both submitted and stored.
@@ -194,7 +196,8 @@ class FillPdfSettingsFormTest extends BrowserTestBase {
       'backend' => 'pdftk',
       'pdftk_path' => 'xyz',
     ];
-    $this->drupalPostForm(Url::fromRoute('fillpdf.settings'), $edit, 'Save configuration');
+    $this->drupalGet(Url::fromRoute('fillpdf.settings'));
+    $this->submitForm($edit, 'Save configuration');
 
     // The validation handler kicked in.
     $this->assertSession()->pageTextNotContains('The configuration options have been saved.');
@@ -227,7 +230,7 @@ class FillPdfSettingsFormTest extends BrowserTestBase {
       'example_setting' => 'x',
       'fillpdf_service_api_key' => 'Invalid, just playing around.',
     ];
-    $this->drupalPostForm(NULL, $edit, 'Save configuration');
+    $this->submitForm($edit, 'Save configuration');
 
     // The 'test' radio option is present and working.
     $this->assertSession()->pageTextNotContains('An illegal choice has been detected.');
@@ -243,7 +246,7 @@ class FillPdfSettingsFormTest extends BrowserTestBase {
 
     // Try again with a valid value.
     $edit['example_setting'] = 'xyz';
-    $this->drupalPostForm(NULL, $edit, 'Save configuration');
+    $this->submitForm($edit, 'Save configuration');
 
     // This time, our custom validation handler passes.
     $this->assertSession()->pageTextNotContains('Not a valid value.');
diff --git a/tests/src/Functional/FillPdfUploadTestBase.php b/tests/src/Functional/FillPdfUploadTestBase.php
index eebf17a..8ef5e7f 100644
--- a/tests/src/Functional/FillPdfUploadTestBase.php
+++ b/tests/src/Functional/FillPdfUploadTestBase.php
@@ -56,7 +56,7 @@ abstract class FillPdfUploadTestBase extends FillPdfTestBase {
 
     // Try uploading a text file in the managed file widget.
     $edit = ['files[upload_pdf]' => $this->getTestFile('text')->getFileUri()];
-    $this->drupalPostForm(NULL, $edit, $op);
+    $this->submitForm($edit, $op);
 
     // Whether submitted or just uploaded, the validation should set an error
     // and the file shouldn't end up being uploaded.
@@ -103,7 +103,7 @@ abstract class FillPdfUploadTestBase extends FillPdfTestBase {
 
     // Upload PDF test file.
     $edit = ['files[upload_pdf]' => $this->getTestPdfPath('fillpdf_test_v3.pdf')];
-    $this->drupalPostForm(NULL, $edit, $op);
+    $this->submitForm($edit, $op);
 
     // Whether submitted or just uploaded, at least temporarily the file should
     // exist now both as an object and physically on the disk.
@@ -129,7 +129,7 @@ abstract class FillPdfUploadTestBase extends FillPdfTestBase {
 
         // Now remove the PDF file again. The temporary file should now be
         // removed both from the disk and the database.
-        $this->drupalPostForm(NULL, NULL, self::OP_REMOVE);
+        $this->submitForm([], self::OP_REMOVE);
         $this->assertFileDoesNotExist($new_file->getFileUri());
         // @todo Simplify once Core bug gets fixed.
         // @see https://www.drupal.org/project/drupal/issues/3043127
diff --git a/tests/src/Functional/HandlePdfControllerTest.php b/tests/src/Functional/HandlePdfControllerTest.php
index 5208050..43897f3 100644
--- a/tests/src/Functional/HandlePdfControllerTest.php
+++ b/tests/src/Functional/HandlePdfControllerTest.php
@@ -76,7 +76,8 @@ class HandlePdfControllerTest extends FillPdfUploadTestBase {
     $edit = [
       'scheme' => 'public',
     ];
-    $this->drupalPostForm("admin/structure/fillpdf/{$form_id}", $edit, 'Save');
+    $this->drupalGet("admin/structure/fillpdf/{$form_id}");
+    $this->submitForm($edit, 'Save');
 
     $fid_before = $this->getLastFileId();
     $fillpdf_route = Url::fromRoute('fillpdf.populate_pdf', [], [
@@ -107,7 +108,8 @@ class HandlePdfControllerTest extends FillPdfUploadTestBase {
       'scheme' => 'public',
       'destination_redirect[value]' => TRUE,
     ];
-    $this->drupalPostForm("admin/structure/fillpdf/{$form_id}", $edit, 'Save');
+    $this->drupalGet("admin/structure/fillpdf/{$form_id}");
+    $this->submitForm($edit, 'Save');
 
     $fid_before = $this->getLastFileId();
     $fillpdf_route = Url::fromRoute('fillpdf.populate_pdf', [], [
@@ -139,7 +141,8 @@ class HandlePdfControllerTest extends FillPdfUploadTestBase {
       'scheme' => 'public',
       'destination_path[0][value]' => '[current-date:html_year]-[user:account-name]-[node:title]',
     ];
-    $this->drupalPostForm("admin/structure/fillpdf/{$form_id}", $edit, 'Save');
+    $this->drupalGet("admin/structure/fillpdf/{$form_id}");
+    $this->submitForm($edit, 'Save');
 
     $year = date('Y');
     $node1_id = $this->testNodes[1]->id();
@@ -225,7 +228,7 @@ class HandlePdfControllerTest extends FillPdfUploadTestBase {
       'scheme' => 'public',
       'destination_path[0][value]' => 'test',
     ];
-    $this->drupalPostForm(NULL, $edit, 'Save');
+    $this->submitForm($edit, 'Save');
 
     $fillpdf_route = Url::fromRoute('fillpdf.populate_pdf', [], [
       'query' => [
@@ -271,7 +274,7 @@ class HandlePdfControllerTest extends FillPdfUploadTestBase {
       'scheme' => 'private',
       'destination_path[0][value]' => 'test',
     ];
-    $this->drupalPostForm(NULL, $edit, 'Save');
+    $this->submitForm($edit, 'Save');
 
     $fillpdf_route = Url::fromRoute('fillpdf.populate_pdf', [], [
       'query' => [
diff --git a/tests/src/Functional/PdfWebformPopulationTest.php b/tests/src/Functional/PdfWebformPopulationTest.php
index 7750048..86825ee 100644
--- a/tests/src/Functional/PdfWebformPopulationTest.php
+++ b/tests/src/Functional/PdfWebformPopulationTest.php
@@ -59,7 +59,8 @@ class PdfWebformPopulationTest extends FillPdfTestBase {
     // Create a test submission for our Contact form.
     $contact_form = Webform::load('fillpdf_contact');
     $contact_form_test_route = Url::fromRoute('entity.webform.test_form', ['webform' => $contact_form->id()]);
-    $this->drupalPostForm($contact_form_test_route, [], $this->t('Send message'));
+    $this->drupalGet($contact_form_test_route);
+    $this->submitForm([], $this->t('Send message'));
 
     // Load the submission.
     $this->testSubmission = WebformSubmission::load($this->getLastSubmissionId($contact_form));
diff --git a/tests/src/Functional/UninstallTest.php b/tests/src/Functional/UninstallTest.php
index f7b7e6c..24f2cba 100644
--- a/tests/src/Functional/UninstallTest.php
+++ b/tests/src/Functional/UninstallTest.php
@@ -67,7 +67,7 @@ class UninstallTest extends BrowserTestBase {
     // Now delete all fillpdf forms.
     $this->drupalGet(Url::fromRoute('system.prepare_modules_entity_uninstall', ['entity_type_id' => 'fillpdf_form']));
     $this->assertSession()->pageTextContains('Are you sure you want to delete all fillpdf form entities?');
-    $this->drupalPostForm(NULL, [], 'Delete all fillpdf form entities');
+    $this->submitForm([], 'Delete all fillpdf form entities');
     $this->assertSession()->pageTextContains('All fillpdf form entities have been deleted');
 
     // Make sure all fillpdf form fields have been deleted as well.
@@ -76,9 +76,10 @@ class UninstallTest extends BrowserTestBase {
 
     // Now go back to the uninstall page and uninstall fillpdf_test and fillpdf.
     foreach (['fillpdf_test', 'fillpdf'] as $module) {
-      $this->drupalPostForm(Url::fromRoute('system.modules_uninstall'), ["uninstall[$module]" => TRUE], 'Uninstall');
+      $this->drupalGet(Url::fromRoute('system.modules_uninstall'));
+      $this->submitForm(["uninstall[$module]" => TRUE], 'Uninstall');
       $this->assertSession()->pageTextContains('The following modules will be completely uninstalled from your site, and all data from these modules will be lost');
-      $this->drupalPostForm(NULL, [], 'Uninstall');
+      $this->submitForm([], 'Uninstall');
       $this->assertSession()->pageTextContains('The selected modules have been uninstalled');
     }
   }
diff --git a/tests/src/Traits/TestFillPdfTrait.php b/tests/src/Traits/TestFillPdfTrait.php
index 946ec5c..3bfd4e7 100644
--- a/tests/src/Traits/TestFillPdfTrait.php
+++ b/tests/src/Traits/TestFillPdfTrait.php
@@ -63,7 +63,8 @@ trait TestFillPdfTrait {
       'backend' => 'local_service',
       'local_service_endpoint' => $localServerEndpoint ?: 'http://127.0.0.1:8085',
     ];
-    $this->drupalPostForm('admin/config/media/fillpdf', $edit, t('Save configuration'));
+    $this->drupalGet('admin/config/media/fillpdf');
+    $this->submitForm($edit, t('Save configuration'));
   }
 
   /**
@@ -82,7 +83,8 @@ trait TestFillPdfTrait {
       'fillpdf_service_api_key' => $api_key,
       'fillpdf_service_api_endpoint' => $api_endpoint,
     ];
-    $this->drupalPostForm('admin/config/media/fillpdf', $edit, t('Save configuration'));
+    $this->drupalGet('admin/config/media/fillpdf');
+    $this->submitForm($edit, t('Save configuration'));
   }
 
   /**
@@ -112,7 +114,8 @@ trait TestFillPdfTrait {
     $edit = [
       'files[upload_pdf]' => $path ?? NULL,
     ];
-    $this->drupalPostForm('admin/structure/fillpdf', $edit, 'Create');
+    $this->drupalGet('admin/structure/fillpdf');
+    $this->submitForm($edit, 'Create');
     $this->assertSession()->statusCodeEquals(200);
   }
 
-- 
GitLab