WebformExampleElementTest.php in Webform 8.5
File
modules/webform_example_element/tests/src/Functional/WebformExampleElementTest.php
View source
<?php
namespace Drupal\Tests\webform_example_element\Functional;
use Drupal\Tests\webform\Functional\WebformBrowserTestBase;
use Drupal\webform\Entity\Webform;
use Drupal\webform\Entity\WebformSubmission;
class WebformExampleElementTest extends WebformBrowserTestBase {
public static $modules = [
'webform_example_element',
];
public function testWebformExampleElement() {
$webform = Webform::load('webform_example_element');
$this
->drupalGet('/webform/webform_example_element');
$this
->assertRaw('<div class="js-form-item form-item js-form-type-webform-example-element form-item-webform-example-element js-form-item-webform-example-element">');
$this
->assertRaw('<label for="edit-webform-example-element">Webform Example Element</label>');
$this
->assertRaw('<input data-drupal-selector="edit-webform-example-element" type="text" id="edit-webform-example-element" name="webform_example_element" value="" size="60" class="form-text webform-example-element" />');
$edit = [
'webform_example_element' => '{Test}',
'webform_example_element_multiple[items][0][_item_]' => '{Test 01}',
];
$sid = $this
->postSubmission($webform, $edit);
$webform_submission = WebformSubmission::load($sid);
$this
->assertEqual($webform_submission
->getElementData('webform_example_element'), '{Test}');
$this
->assertEqual($webform_submission
->getElementData('webform_example_element_multiple'), [
'{Test 01}',
]);
}
}