You are here

public function WebformNodeElementFunctionalTest::testGet in Webform Node Element 8

Test that the webform node element is displayed on the form.

File

tests/src/Functional/WebformNodeElementFunctionalTest.php, line 31

Class

WebformNodeElementFunctionalTest
Example of webform browser test.

Namespace

Drupal\Tests\webform_node_element\Functional

Code

public function testGet() {
  $node_title = "Webform Node Element Test";
  $node = $this
    ->drupalCreateNode([
    'type' => 'article',
    'title' => $node_title,
  ]);

  // Create webform.

  /** @var \Drupal\webform\WebformInterface $webform */
  $webform = Webform::create([
    'id' => 'webform_test',
  ]);
  $elements = [
    'webform_node_element_test' => [
      [
        '#type' => 'webform_node_element',
        '#webform_node_element_nid' => $node
          ->id(),
      ],
    ],
  ];
  $webform
    ->setElements($elements);
  $webform
    ->save();
  $url = $webform
    ->toUrl()
    ->toString();
  $html = $this
    ->drupalGet($url);
  $this
    ->assertText($node_title);
}