You are here

protected function WebformBrowserTestTrait::createWebform in Webform 6.x

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

Create a webform.

Parameters

array|null $values: (optional) Array of values.

array|null $elements: (optional) Array of elements.

array $settings: (optional) Webform settings.

Return value

\Drupal\webform\WebformInterface A webform.

5 calls to WebformBrowserTestTrait::createWebform()
WebformBrowserTestBaseTest::testWebformBase in tests/src/Functional/WebformBrowserTestBaseTest.php
Test base helper methods.
WebformFieldTest::testWebformField in tests/src/Functional/Field/WebformFieldTest.php
Tests the webform (entity reference) field.
WebformListBuilderTest::testBulkOperations in tests/src/Functional/WebformListBuilderTest.php
Tests the webform overview bulk operations.
WebformUiElementActionsTest::testActionsElements in modules/webform_ui/tests/src/Functional/WebformUiElementActionsTest.php
Tests actions element.
WebformUiElementTest::testElements in modules/webform_ui/tests/src/Functional/WebformUiElementTest.php
Tests element.

File

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

Class

WebformBrowserTestTrait
Provides convenience methods for webform assertions in browser tests.

Namespace

Drupal\Tests\webform\Traits

Code

protected function createWebform($values = [], array $elements = [], array $settings = []) {

  // Create new webform.
  $id = $this
    ->randomMachineName(8);
  $webform = Webform::create($values + [
    'langcode' => 'en',
    'status' => WebformInterface::STATUS_OPEN,
    'id' => $id,
    'title' => $id,
    'elements' => Yaml::encode($elements),
    'settings' => $settings + Webform::getDefaultSettings(),
  ]);
  $webform
    ->save();
  return $webform;
}