From a13a22bded5d2801b69d23a617ced7fffade487c Mon Sep 17 00:00:00 2001
From: Liam Morland <liam@openplus.ca>
Date: Sat, 11 May 2024 11:42:47 -0400
Subject: [PATCH] Issue #3426100: Make spelling corrections and exceptions

---
 .gitlab-ci.yml                                |  3 +-
 src/Plugin/PdfBackend/PdftkPdfBackend.php     | 12 +++----
 tests/src/Functional/FillPdfFormFormTest.php  |  4 +--
 .../src/Functional/FillPdfUploadTestBase.php  |  2 +-
 .../Functional/HandlePdfControllerTest.php    | 36 +++++++++----------
 tests/src/Traits/TestFillPdfTrait.php         |  6 ++--
 6 files changed, 31 insertions(+), 32 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 436ac1c..dfbc69f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -59,8 +59,7 @@ include:
 #   OPT_IN_TEST_NEXT_MAJOR: '1'
 #   _CURL_TEMPLATES_REF: 'main'
 variables:
-  _CSPELL_WORDS: 'fillpdf, Kaland, pdfs, pdftk, webform, xfdf, Ŧäßð'
-
+  _CSPELL_WORDS: 'autocompletechange, autocompleteclose, edum, ffcf, ffid, filenamehash, fillpdf, Kaland, listbuilder, pdfbackend, pdfs, pdftk, PERCENTSIGN, webform, xfdf, Ŧäßð'
 
 ###################################################################################
 #
diff --git a/src/Plugin/PdfBackend/PdftkPdfBackend.php b/src/Plugin/PdfBackend/PdftkPdfBackend.php
index 716e1af..8af60ed 100644
--- a/src/Plugin/PdfBackend/PdftkPdfBackend.php
+++ b/src/Plugin/PdfBackend/PdftkPdfBackend.php
@@ -133,17 +133,17 @@ class PdftkPdfBackend extends PdfBackendBase implements ContainerFactoryPluginIn
 
     // Build the fields array.
     $fields = [];
-    $fieldindex = -1;
-    foreach ($output as $lineitem) {
-      if ($lineitem == '---') {
-        $fieldindex++;
+    $field_index = -1;
+    foreach ($output as $line_item) {
+      if ($line_item == '---') {
+        $field_index++;
         continue;
       }
       // Separate the data key from the data value.
-      [$key, $value] = explode(':', $lineitem);
+      [$key, $value] = explode(':', $line_item);
       if (in_array($key, array_keys($data_fields_map))) {
         // Trim spaces.
-        $fields[$fieldindex][$data_fields_map[$key]] = trim($value);
+        $fields[$field_index][$data_fields_map[$key]] = trim($value);
       }
     }
 
diff --git a/tests/src/Functional/FillPdfFormFormTest.php b/tests/src/Functional/FillPdfFormFormTest.php
index 1381977..518fa21 100644
--- a/tests/src/Functional/FillPdfFormFormTest.php
+++ b/tests/src/Functional/FillPdfFormFormTest.php
@@ -39,7 +39,7 @@ class FillPdfFormFormTest extends FillPdfUploadTestBase {
       $this->createUser();
     }
 
-    $testcases = [
+    $test_cases = [
       // Test case: no referenceable entity.
       'fillpdf_file_context' => [0, 0, ''],
       // Test case: 1 referenceable entity.
@@ -48,7 +48,7 @@ class FillPdfFormFormTest extends FillPdfUploadTestBase {
       'user' => [26, $this->adminUser->id(), $this->adminUser->label()],
     ];
 
-    foreach ($testcases as $type => [$count, $id, $label]) {
+    foreach ($test_cases as $type => [$count, $id, $label]) {
       // Set a default entity type and check if it's properly saved.
       $this->submitForm(['default_entity_type' => $type], self::OP_SAVE);
       $this->assertSession()->pageTextContains("FillPDF Form has been updated.");
diff --git a/tests/src/Functional/FillPdfUploadTestBase.php b/tests/src/Functional/FillPdfUploadTestBase.php
index 71ecf3c..4f97d22 100644
--- a/tests/src/Functional/FillPdfUploadTestBase.php
+++ b/tests/src/Functional/FillPdfUploadTestBase.php
@@ -79,7 +79,7 @@ abstract class FillPdfUploadTestBase extends FillPdfTestBase {
    *   - FillPdfUploadTestBase::OP_CREATE, or
    *   - FillPdfUploadTestBase::OP_SAVE.
    * @param bool $filename_preexists
-   *   (optional) Whether the testfile has previously been uploaded, so a file
+   *   (optional) Whether the test file has previously been uploaded, so a file
    *   with the same filename preexists. Defaults to FALSE.
    * @param \Drupal\fillpdf\FillPdfFormInterface $form
    *   The FillPDF Form that is being updated. Needed so we can make some
diff --git a/tests/src/Functional/HandlePdfControllerTest.php b/tests/src/Functional/HandlePdfControllerTest.php
index f0f254f..ccdf5bb 100644
--- a/tests/src/Functional/HandlePdfControllerTest.php
+++ b/tests/src/Functional/HandlePdfControllerTest.php
@@ -159,40 +159,40 @@ class HandlePdfControllerTest extends FillPdfUploadTestBase {
     $user_id = $this->adminUser->id();
     $user_name = $this->adminUser->getAccountName();
 
-    $testcases = [];
+    $test_cases = [];
     // Test case 0: no entity.
-    $testcases[1]['entities'] = [];
-    $testcases[1]['expected'] = "{$year}--";
+    $test_cases[1]['entities'] = [];
+    $test_cases[1]['expected'] = "{$year}--";
 
     // Test case 1: existing node.
-    $testcases[1]['entities'] = ["node:{$node1_id}"];
-    $testcases[1]['expected'] = "{$year}--{$node1_title}";
+    $test_cases[1]['entities'] = ["node:{$node1_id}"];
+    $test_cases[1]['expected'] = "{$year}--{$node1_title}";
 
     // Test case 2: two existing nodes.
-    $testcases[2]['entities'] = ["node:{$node1_id}", "node:{$node2_id}"];
-    $testcases[2]['expected'] = "{$year}--{$node2_title}";
+    $test_cases[2]['entities'] = ["node:{$node1_id}", "node:{$node2_id}"];
+    $test_cases[2]['expected'] = "{$year}--{$node2_title}";
 
     // Test case 3: twice the same node.
-    $testcases[3]['entities'] = ["node:{$node1_id}", "node:{$node1_id}"];
-    $testcases[3]['expected'] = "{$year}--{$node1_title}";
+    $test_cases[3]['entities'] = ["node:{$node1_id}", "node:{$node1_id}"];
+    $test_cases[3]['expected'] = "{$year}--{$node1_title}";
 
     // Test case 4: existing user.
-    $testcases[4]['entities'] = ["user:{$user_id}"];
-    $testcases[4]['expected'] = "{$year}-{$user_name}-";
+    $test_cases[4]['entities'] = ["user:{$user_id}"];
+    $test_cases[4]['expected'] = "{$year}-{$user_name}-";
 
     // Test case 5: existing node and existing user.
-    $testcases[5]['entities'] = ["node:{$node1_id}", "user:{$user_id}"];
-    $testcases[5]['expected'] = "{$year}-{$user_name}-{$node1_title}";
+    $test_cases[5]['entities'] = ["node:{$node1_id}", "user:{$user_id}"];
+    $test_cases[5]['expected'] = "{$year}-{$user_name}-{$node1_title}";
 
     // Test case 6: non-existing node.
-    $testcases[6]['entities'] = ["node:123"];
-    $testcases[6]['expected'] = "{$year}--";
+    $test_cases[6]['entities'] = ["node:123"];
+    $test_cases[6]['expected'] = "{$year}--";
 
     // Test case 7: existing node and non-existing user.
-    $testcases[7]['entities'] = ["node:{$node1_id}", "user:456"];
-    $testcases[7]['expected'] = "{$year}--{$node1_title}";
+    $test_cases[7]['entities'] = ["node:{$node1_id}", "user:456"];
+    $test_cases[7]['expected'] = "{$year}--{$node1_title}";
 
-    foreach ($testcases as $id => $case) {
+    foreach ($test_cases as $id => $case) {
       // Hit the generation route.
       $entities = $case['entities'];
       $fillpdf_route = Url::fromRoute('fillpdf.populate_pdf', [], [
diff --git a/tests/src/Traits/TestFillPdfTrait.php b/tests/src/Traits/TestFillPdfTrait.php
index 7401d01..600e403 100644
--- a/tests/src/Traits/TestFillPdfTrait.php
+++ b/tests/src/Traits/TestFillPdfTrait.php
@@ -100,10 +100,10 @@ trait TestFillPdfTrait {
   }
 
   /**
-   * Uploads a specified PDF testfile, if given.
+   * Uploads a specified PDF test file, if given.
    *
    * @param string|null $filename
-   *   (optional) Filename of the PDF testfile. Defaults to NULL.
+   *   (optional) Filename of the PDF test file. Defaults to NULL.
    */
   protected function uploadTestPdf($filename = NULL) {
     if ($filename) {
@@ -141,7 +141,7 @@ trait TestFillPdfTrait {
    * Gets the absolute local filepath of a PDF test file.
    *
    * @param string $filename
-   *   Filename of the PDF testfile.
+   *   Filename of the PDF test file.
    *
    * @return string|false
    *   The absolute locale filepath or FALSE on failure.
-- 
GitLab