You are here

public function PdfUsingMpdfConfigurationFormTest::testConfiguration in PDF using mPDF 8.2

Tests if the configuration saved to Drupal is correct

File

tests/src/Functional/PdfUsingMpdfConfigurationFormTest.php, line 66

Class

PdfUsingMpdfConfigurationFormTest
Class PdfUsingMpdfConfigurationFormTest @package Drupal\Tests\pdf_using_mpdf\Functional

Namespace

Drupal\Tests\pdf_using_mpdf\Functional

Code

public function testConfiguration() {
  $this
    ->drupalLogin($this->adminUser);

  // Set Drupal config
  $active = $this->container
    ->get('config.storage');
  $sync = $this->container
    ->get('config.storage.sync');
  $this
    ->copyConfig($active, $sync);
  $sync
    ->write('pdf_using_mpdf.settings', $this->mPdfConfig);
  $this
    ->configImporter()
    ->import();
  $this
    ->drupalGet('admin/config/user-interface/mpdf');

  // Assert form values
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-pdf-filename')
    ->getValue(), 'pdf-test-file');
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-pdf-save-option-1')
    ->getValue(), '1');
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-pdf-set-author')
    ->getValue(), 'pdf-test-author');
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-pdf-set-subject')
    ->getValue(), 'pdf-test-subject');
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-pdf-set-creator')
    ->getValue(), 'pdf-test-creator');
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-margin-top')
    ->getValue(), '24');
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-margin-right')
    ->getValue(), '22');
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-margin-bottom')
    ->getValue(), '24');
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-margin-left')
    ->getValue(), '22');
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-margin-header')
    ->getValue(), '11');
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-margin-footer')
    ->getValue(), '11');
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-pdf-font-size')
    ->getValue(), '16');
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-pdf-default-font')
    ->getValue(), 'dejavusanscondensed');
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-pdf-page-size')
    ->getValue(), 'A1');
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-dpi')
    ->getValue(), '101');
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-img-dpi')
    ->getValue(), '105');
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-orientation')
    ->getValue(), 'L');
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-watermark-opacity')
    ->getValue(), '0.5');
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-watermark-option-0')
    ->getValue(), '0');
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-pdf-watermark-text')
    ->getValue(), 'pdf-watermark-test-text');
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-pdf-header')
    ->getValue(), 'pdf-test-header');
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-pdf-footer')
    ->getValue(), 'pdf-test-footer');
  $this
    ->assertEqual($this
    ->getSession()
    ->getPage()
    ->findById('edit-pdf-css-file')
    ->getValue(), '/path/to/css/file.css');
  $this
    ->drupalLogout();
}