You are here

public function FillPdfSettingsFormTest::testBackendPdftk in FillPDF 5.0.x

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

Tests the backend settings with the 'pdftk' backend.

File

tests/src/Functional/FillPdfSettingsFormTest.php, line 197

Class

FillPdfSettingsFormTest
@coversDefaultClass \Drupal\fillpdf\Form\FillPdfSettingsForm @group fillpdf

Namespace

Drupal\Tests\fillpdf\Functional

Code

public function testBackendPdftk() {

  // FillPDF is not yet configured.
  // Try configuring FillPDF with the 'pdftk' backend, yet an invalid path.
  $edit = [
    'template_scheme' => 'private',
    'backend' => 'pdftk',
    'pdftk_path' => 'xyz',
  ];
  $this
    ->drupalPostForm(Url::fromRoute('fillpdf.settings'), $edit, 'Save configuration');

  // The validation handler kicked in.
  $this
    ->assertSession()
    ->pageTextNotContains('The configuration options have been saved.');
  $this
    ->assertSession()
    ->pageTextContains('The path you have entered for pdftk is invalid. Please enter a valid path.');

  // Verify the new values have been submitted, but *not* saved.
  foreach ($edit as $field => $value) {
    $this
      ->assertSession()
      ->fieldValueEquals($field, $value);
    $this
      ->assertEqual($this
      ->config('fillpdf.settings')
      ->get($field), NULL);
  }
}