You are here

protected function PdfWebformPopulationTest::setUp in FillPDF 5.0.x

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

Overrides FillPdfTestBase::setUp

File

tests/src/Functional/PdfWebformPopulationTest.php, line 45

Class

PdfWebformPopulationTest
Tests Webform population and image stamping.

Namespace

Drupal\Tests\fillpdf\Functional

Code

protected function setUp() : void {

  // @todo: Stop skipping this test when Webform has Drupal 9 support.
  if (version_compare(substr(\Drupal::VERSION, 0, 1), 9, '>=')) {
    $this
      ->markTestSkipped('Webform is not yet compatible with Drupal 9, so skipping these tests.');
  }
  parent::setUp();

  // Add some roles to this user.
  $existing_user_roles = $this->adminUser
    ->getRoles(TRUE);
  $role_to_modify = Role::load(end($existing_user_roles));

  // Grant additional permissions to this user.
  $this
    ->grantPermissions($role_to_modify, [
    'administer webform',
    'access webform submission log',
    'create webform',
  ]);

  // Create a test submission for our Contact form.
  $contact_form = Webform::load('fillpdf_contact');
  $contact_form_test_route = Url::fromRoute('entity.webform.test_form', [
    'webform' => $contact_form
      ->id(),
  ]);
  $this
    ->drupalPostForm($contact_form_test_route, [], t('Send message'));

  // Load the submission.
  $this->testSubmission = WebformSubmission::load($this
    ->getLastSubmissionId($contact_form));
}