You are here

public function FillPdfSettingsFormTest::testBackendFillPdfService in FillPDF 8.4

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

Tests the backend settings with the 'fillpdf_service' backend.

File

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

Class

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

Namespace

Drupal\Tests\fillpdf\Functional

Code

public function testBackendFillPdfService() {

  // FillPDF is not yet configured. The settings form is however initialized
  // with the 'fillpdf_service' backend. Save that configuration.
  $this
    ->drupalPostForm(Url::fromRoute('fillpdf.settings'), NULL, 'Save configuration');

  // There's currently no validation, so the 'backend' setting should be
  // both submitted and stored.
  $this
    ->assertSession()
    ->pageTextContains('The configuration options have been saved.');
  $this
    ->assertSession()
    ->fieldValueEquals('backend', 'fillpdf_service');
  $this
    ->assertEqual($this
    ->config('fillpdf.settings')
    ->get('backend'), 'fillpdf_service');

  // Now add an API key and save again.
  $this
    ->drupalPostForm(NULL, [
    'fillpdf_service_api_key' => 'Invalid, just playing around.',
  ], 'Save configuration');

  // There's currently no validation, so the obviously invalid
  // 'fillpdf_service_api_key' should be both submitted and stored.
  $this
    ->assertSession()
    ->pageTextContains('The configuration options have been saved.');
  $this
    ->assertSession()
    ->fieldValueEquals('fillpdf_service_api_key', 'Invalid, just playing around.');
  $this
    ->assertEqual($this
    ->config('fillpdf.settings')
    ->get('fillpdf_service_api_key'), 'Invalid, just playing around.');
}