You are here

public function WebformSubmissionStorageTest::testStorage in Webform 8.5

Same name and namespace in other branches
  1. 6.x tests/src/Kernel/WebformSubmissionStorageTest.php \Drupal\Tests\webform\Kernel\WebformSubmissionStorageTest::testStorage()

Test webform submission storage.

File

tests/src/Kernel/WebformSubmissionStorageTest.php, line 39

Class

WebformSubmissionStorageTest
Tests webform submission storage.

Namespace

Drupal\Tests\webform\Kernel

Code

public function testStorage() {
  $webform = Webform::create([
    'id' => $this
      ->randomMachineName(),
  ]);
  $webform
    ->save();
  $webform_submission = WebformSubmission::create([
    'webform_id' => $webform
      ->id(),
  ]);
  $webform_submission
    ->save();

  // Check load by entities.
  $webform_submissions = \Drupal::entityTypeManager()
    ->getStorage('webform_submission')
    ->loadByEntities($webform);
  $this
    ->assertEquals($webform_submission
    ->id(), key($webform_submissions));
}