You are here

public function PdfPopulationTest::testSamplePdf in FillPDF 8.4

Same name and namespace in other branches
  1. 5.0.x tests/src/Functional/PdfPopulationTest.php \Drupal\Tests\fillpdf\Functional\PdfPopulationTest::testSamplePdf()

Tests sample mapping.

File

tests/src/Functional/PdfPopulationTest.php, line 124

Class

PdfPopulationTest
Tests Core entity population and image stamping.

Namespace

Drupal\Tests\fillpdf\Functional

Code

public function testSamplePdf() {
  $this
    ->uploadTestPdf('fillpdf_test_v3.pdf');

  // Load the FillPdf Form.
  $fillpdf_form = FillPdfForm::load($this
    ->getLatestFillPdfForm());

  // Hit the generation route, check the results from the test backend plugin.
  $url = $this->linkManipulator
    ->generateLink([
    'fid' => $fillpdf_form
      ->id(),
    'sample' => 1,
  ]);
  $this
    ->drupalGet($url);

  // We don't actually care about downloading the fake PDF. We just want to
  // check what happened in the backend.
  $populate_result = $this->container
    ->get('state')
    ->get('fillpdf_test.last_populated_metadata');
  self::assertEquals('<TextField1>', $populate_result['field_mapping']['fields']['TextField1'], 'Sample field mapped properly.');
}