public function PdfPopulationTest::testDuplicateFieldHandling in FillPDF 5.0.x
Test that duplicate fields get filtered out.
File
- tests/
src/ Functional/ PdfPopulationTest.php, line 222
Class
- PdfPopulationTest
- Tests Core entity population and image stamping.
Namespace
Drupal\Tests\fillpdf\FunctionalCode
public function testDuplicateFieldHandling() {
$this
->uploadTestPdf('fillpdf_test_v3.pdf');
$fillpdf_form = FillPdfForm::load($this
->getLatestFillPdfForm());
// Get the field definitions from the actually created form and sort.
$actual_keys = [];
foreach (array_keys($fillpdf_form
->getFormFields()) as $pdf_key) {
$actual_keys[] = $pdf_key;
}
sort($actual_keys);
// Get the fields from the fixture and sort.
$expected_keys = [];
foreach (TestPdfBackend::getParseResult() as $expected_field) {
$expected_keys[] = $expected_field['name'];
}
sort($expected_keys);
// Now compare. InputHelper::attachPdfToForm() filtered out the duplicate,
// so the count differs, but not the actual values.
$this
->assertCount(5, $expected_keys);
$this
->assertCount(4, $actual_keys);
$differences = array_diff($expected_keys, $actual_keys);
self::assertEmpty($differences, 'Parsed fields are in fixture match.');
}