You are here

public function WebformAccessSubmissionViewsTest::testWebformAccessSubmissionViewsTest in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_access/tests/src/Functional/WebformAccessSubmissionViewsTest.php \Drupal\Tests\webform_access\Functional\WebformAccessSubmissionViewsTest::testWebformAccessSubmissionViewsTest()

Tests webform access submission views.

File

modules/webform_access/tests/src/Functional/WebformAccessSubmissionViewsTest.php, line 26

Class

WebformAccessSubmissionViewsTest
Tests for webform access submission views.

Namespace

Drupal\Tests\webform_access\Functional

Code

public function testWebformAccessSubmissionViewsTest() {

  // Create a test submission for each node and user account.
  $webform = Webform::load('contact');

  /** @var \Drupal\webform\WebformSubmissionGenerateInterface $submission_generate */
  $submission_generate = \Drupal::service('webform_submission.generate');
  foreach ($this->nodes as $node) {
    foreach ($this->users as $user) {
      WebformSubmission::create([
        'webform_id' => 'contact',
        'entity_type' => 'node',
        'entity_id' => $node
          ->id(),
        'uid' => $user
          ->id(),
        'data' => $submission_generate
          ->getData($webform),
      ])
        ->save();
    }
  }
  $this
    ->checkUserSubmissionAccess($webform, $this->users);
}