You are here

protected function WebformVariantRandomizeJavaScriptTest::getSavedVariantId in Webform 8.5

Same name and namespace in other branches
  1. 6.x tests/src/FunctionalJavascript/Variant/WebformVariantRandomizeJavaScriptTest.php \Drupal\Tests\webform\FunctionalJavascript\Variant\WebformVariantRandomizeJavaScriptTest::getSavedVariantId()

Gets the persisted variant from the current browsing session.

Return value

string|null The persisted variant id or NULL if one is not persisted.

1 call to WebformVariantRandomizeJavaScriptTest::getSavedVariantId()
WebformVariantRandomizeJavaScriptTest::testVariantRandomize in tests/src/FunctionalJavascript/Variant/WebformVariantRandomizeJavaScriptTest.php
Test variant randomize.

File

tests/src/FunctionalJavascript/Variant/WebformVariantRandomizeJavaScriptTest.php, line 28

Class

WebformVariantRandomizeJavaScriptTest
Tests for the webform variant randomize.

Namespace

Drupal\Tests\webform\FunctionalJavascript\Variant

Code

protected function getSavedVariantId() {
  $script = <<<JS
(function() {
  var key = 'Drupal.webform.test_variant_randomize.variant.letter';
  return window.sessionStorage.getItem(key);
})();
JS;
  return $this
    ->getSession()
    ->evaluateScript($script);
}