diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 436ac1ceb2ca48348425f3a21fa2508aac7f4691..dfbc69fc99f51d8d8181c24a83352403d783dcc2 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 716e1afd03730e03cef57b22d0027cb863170204..8af60edc3a8f13713204fb9373d71e0e2ab679ba 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 13819775436a3a7c05e8c3e0a4e939c1157d03f2..518fa21af6dfed1f74a72df50631c57c9d968604 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 71ecf3c6de594055ba96e9730c967f823b6f5ec6..4f97d2204cc0866b91b037097455c147060c1dc0 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 f0f254f97d04045216c8fb95c68ac4748d346873..ccdf5bb01a86e829059ea19901e6d6f60523adf3 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 7401d01e4230080c12ab2643bfa5446419e83557..600e40339697938d66c85f6bcfaf1dce72e65957 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.