You are here

public function FillPdfFormFormTest::testFormFormUpload in FillPDF 8.4

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

Tests the FillPdfForm entity's edit form.

File

tests/src/Functional/FillPdfFormFormTest.php, line 93

Class

FillPdfFormFormTest
@coversDefaultClass \Drupal\fillpdf\Form\FillPdfFormForm @group fillpdf

Namespace

Drupal\Tests\fillpdf\Functional

Code

public function testFormFormUpload() {
  $this
    ->uploadTestPdf('fillpdf_test_v3.pdf');
  $latest_fid = $this
    ->getLatestFillPdfForm();
  $latest_fillpdf_form = FillPdfForm::load($latest_fid);
  $max_fid_after = $latest_fillpdf_form->fid->value;
  $this
    ->drupalGet('admin/structure/fillpdf/' . $max_fid_after);
  $this
    ->assertSession()
    ->statusCodeEquals(200);

  // Check if the 'accept' attribute is correctly set.
  $this
    ->assertSession()
    ->elementAttributeContains('css', 'input#edit-upload-pdf-upload', 'accept', 'application/pdf');

  // Run all upload tests.
  $this
    ->assertNotUploadTextFile(self::OP_UPLOAD);
  $this
    ->assertNotUploadTextFile(self::OP_SAVE);
  $this
    ->assertUploadPdfFile(self::OP_UPLOAD, TRUE);
  $pdf_fields = $latest_fillpdf_form
    ->getFormFields();
  FillPdfTestBase::mapFillPdfFieldsToEntityFields('node', $pdf_fields);
  $this
    ->assertUploadPdfFile(self::OP_SAVE, TRUE, $latest_fillpdf_form);
}