WebformNodeElementFunctionalTest.php in Webform Node Element 8
File
tests/src/Functional/WebformNodeElementFunctionalTest.php
View source
<?php
namespace Drupal\Tests\webform_node_element\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\webform\Entity\Webform;
class WebformNodeElementFunctionalTest extends BrowserTestBase {
public static $modules = [
'node',
'filter',
'webform',
'webform_node_element',
];
public function setup() {
parent::setup();
$this
->drupalCreateContentType([
'type' => 'article',
'name' => 'Basic Article',
]);
}
public function testGet() {
$node_title = "Webform Node Element Test";
$node = $this
->drupalCreateNode([
'type' => 'article',
'title' => $node_title,
]);
$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);
}
}