You are here

protected function TestFillPdfTrait::configureFillPdf in FillPDF 5.0.x

Same name and namespace in other branches
  1. 8.4 tests/src/Traits/TestFillPdfTrait.php \Drupal\Tests\fillpdf\Traits\TestFillPdfTrait::configureFillPdf()

Configures schemes and backend.

Parameters

array $configuration: (optional) Associative array containing configuration to be set. This may contain the following keys:

  • 'allowed_schemes': string[] (default: ['public', 'private']
  • 'template_scheme': string (default: the site default)
  • 'backend': string (default: 'test')
14 calls to TestFillPdfTrait::configureFillPdf()
FillPdfFormDeleteFormTest::setUp in tests/src/Functional/FillPdfFormDeleteFormTest.php
FillPdfFormDuplicateFormTest::setUp in tests/src/Functional/FillPdfFormDuplicateFormTest.php
FillPdfFormFormTest::testStorageSettings in tests/src/Functional/FillPdfFormFormTest.php
Tests the FillPdfForm entity's edit form.
FillPdfFormImportFormTest::setUp in tests/src/Functional/FillPdfFormImportFormTest.php
FillPdfSettingsFormTest::testTemplateSchemeDummyRemote in tests/src/Functional/FillPdfSettingsFormTest.php
Tests the scheme settings with the 'dummy_remote' stream wrapper.

... See full list

File

tests/src/Traits/TestFillPdfTrait.php, line 22

Class

TestFillPdfTrait
Provides methods for testing FillPdf.

Namespace

Drupal\Tests\fillpdf\Traits

Code

protected function configureFillPdf(array $configuration = []) {

  // Merge in defaults.
  $configuration += [
    'allowed_schemes' => [
      'public',
      'private',
    ],
    'template_scheme' => $this
      ->config('system.file')
      ->get('default_scheme'),
    'backend' => 'test',
  ];

  /** @var \Drupal\Core\Config\ConfigFactoryInterface $config_factory */
  $config_factory = $this->container
    ->get('config.factory');

  // Set FillPDF backend and scheme.
  $config = $config_factory
    ->getEditable('fillpdf.settings')
    ->set('allowed_schemes', $configuration['allowed_schemes'])
    ->set('template_scheme', $configuration['template_scheme'])
    ->set('backend', $configuration['backend']);

  // PDFtk needs to have the correct locale set in the environment or the
  // test will fail.
  if ($configuration['backend'] === 'pdftk') {

    /** @var \Drupal\fillpdf\ShellManagerInterface $shell_manager */
    $shell_manager = $this->container
      ->get('fillpdf.shell_manager');
    $locales = $shell_manager
      ->getInstalledLocales();
    $config
      ->set('shell_locale', isset($locales['en_US.UTF-8']) ? 'en_US.UTF-8' : 'en_US.utf8');
  }
  $config
    ->save();
}