You are here

protected function WebformBrowserTestTrait::getLastSubmissionId in Webform 6.x

Same name and namespace in other branches
  1. 8.5 tests/src/Traits/WebformBrowserTestTrait.php \Drupal\Tests\webform\Traits\WebformBrowserTestTrait::getLastSubmissionId()

Get the last submission id.

Parameters

\Drupal\webform\WebformInterface $webform: A webform.

Return value

int|null The last submission id. NULL if saving of results is disabled.

16 calls to WebformBrowserTestTrait::getLastSubmissionId()
WebformBrowserTestTrait::postSubmission in tests/src/Traits/WebformBrowserTestTrait.php
Post a new submission to a webform.
WebformBrowserTestTrait::postSubmissionTest in tests/src/Traits/WebformBrowserTestTrait.php
Post a new test submission to a webform.
WebformCompositeCustomFileTest::testCustom in tests/src/Functional/Composite/WebformCompositeCustomFileTest.php
Test custom composite element.
WebformElementActionsTest::testActions in tests/src/Functional/Element/WebformElementActionsTest.php
Tests actions element.
WebformElementPrepopulateTest::testElementPrepopulate in tests/src/Functional/Element/WebformElementPrepopulateTest.php
Test element prepopulate.

... See full list

File

tests/src/Traits/WebformBrowserTestTrait.php, line 355

Class

WebformBrowserTestTrait
Provides convenience methods for webform assertions in browser tests.

Namespace

Drupal\Tests\webform\Traits

Code

protected function getLastSubmissionId(WebformInterface $webform) {
  if ($webform
    ->getSetting('results_disabled')) {
    return NULL;
  }

  // Get submission sid.
  $url = UrlHelper::parse($this
    ->getUrl());
  if (isset($url['query']['sid'])) {
    return $url['query']['sid'];
  }
  else {
    $entity_ids = $this->container
      ->get('entity_type.manager')
      ->getStorage('webform_submission')
      ->getQuery()
      ->sort('sid', 'DESC')
      ->condition('webform_id', $webform
      ->id())
      ->accessCheck(FALSE)
      ->execute();
    return reset($entity_ids);
  }
}