You are here

public function FillPdfSettingsFormTest::testSettingsFormDefaults 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::testSettingsFormDefaults()

Tests the scheme settings with the site default.

File

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

Class

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

Namespace

Drupal\Tests\fillpdf\Functional

Code

public function testSettingsFormDefaults() {

  // FillPDF is not yet configured.
  // Verify the settings form is however initialized with the site default
  // scheme, which at this point should be 'public', and with the
  // 'fillpdf_service' backend.
  $this
    ->drupalGet(Url::fromRoute('fillpdf.settings'));
  $this
    ->assertSession()
    ->pageTextContains('Public files (site default)');
  $this
    ->assertSession()
    ->checkboxChecked('edit-template-scheme-public');
  $this
    ->assertSession()
    ->checkboxChecked('edit-backend-fillpdf-service');

  // Now set the site default to 'private'.
  $config = $this->container
    ->get('config.factory')
    ->getEditable('system.file')
    ->set('default_scheme', 'private');
  $config
    ->save();

  // The form should now be initialized with the new site default scheme,
  // while the backend should remain unchanged.
  $this
    ->drupalGet(Url::fromRoute('fillpdf.settings'));
  $this
    ->assertSession()
    ->pageTextContains('Private files (site default)');
  $this
    ->assertSession()
    ->checkboxChecked('edit-template-scheme-private');
  $this
    ->assertSession()
    ->checkboxChecked('edit-backend-fillpdf-service');
}