You are here

public function FillPdfFormDeleteFormTest::testDeleteForm in FillPDF 5.0.x

Same name and namespace in other branches
  1. 8.4 tests/src/Functional/FillPdfFormDeleteFormTest.php \Drupal\Tests\fillpdf\Functional\FillPdfFormDeleteFormTest::testDeleteForm()

Tests the cancel link works.

File

tests/src/Functional/FillPdfFormDeleteFormTest.php, line 81

Class

FillPdfFormDeleteFormTest
@coversDefaultClass \Drupal\fillpdf\Form\FillPdfFormDeleteForm @group fillpdf

Namespace

Drupal\Tests\fillpdf\Functional

Code

public function testDeleteForm() {
  $this
    ->uploadTestPdf('fillpdf_test_v3.pdf');
  $form_id = $this
    ->getLatestFillPdfForm();

  // Verify the FillPdfForm's fields are stored.
  $field_ids = \Drupal::entityQuery('fillpdf_form_field')
    ->condition('fillpdf_form', $form_id)
    ->execute();
  $this
    ->assertCount(4, $field_ids, "4 FillPdfFormFields have been created.");

  // We're on the edit form. Click 'Delete' and confirm deletion.
  $this
    ->clickLink('Delete');
  $this
    ->drupalPostForm(NULL, NULL, 'Delete');
  $this
    ->assertSession()
    ->pageTextContains('FillPDF form deleted.');
  $this
    ->assertSession()
    ->addressEquals(Url::fromRoute('fillpdf.forms_admin'));

  // Now verify the FillPdfForm and its fields have actually been deleted.
  $this
    ->assertNull(FillPdfForm::load($form_id), "The FillPdfForm #{$form_id} doesn't exist anymore.");
  foreach ($field_ids as $id) {
    $this
      ->assertNull(FillPdfFormField::load($id), "The FillPdfFormField #{$id} doesn't exist anymore.");
  }
}