WebformFormPropertiesTest.php in Webform 8.5
File
tests/src/Functional/Form/WebformFormPropertiesTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional\Form;
use Drupal\Tests\webform\Functional\WebformBrowserTestBase;
class WebformFormPropertiesTest extends WebformBrowserTestBase {
protected static $testWebforms = [
'test_form_properties',
'test_element_invalid',
];
public function testProperties() {
global $base_path;
$this
->drupalGet('/webform/test_element_invalid');
$this
->assertRaw('Unable to display this webform. Please contact the site administrator.');
$this
->drupalGet('/webform/test_form_properties');
$this
->assertPattern('/Form prefix<form /');
$this
->assertPattern('/<\\/form>\\s+Form suffix/');
$this
->assertRaw('<form class="webform-submission-form webform-submission-add-form webform-submission-test-form-properties-form webform-submission-test-form-properties-add-form test-form-properties js-webform-details-toggle webform-details-toggle" invalid="invalid" style="border: 10px solid red; padding: 1em;" data-drupal-selector="webform-submission-test-form-properties-add-form" action="https://www.google.com/search" method="get" id="webform-submission-test-form-properties-add-form" accept-charset="UTF-8">');
$this
->drupalLogin($this->rootUser);
$edit = [
'attributes[class][select][]' => [
'form--inline clearfix',
'_other_',
],
'attributes[class][other]' => 'test-form-properties',
'attributes[style]' => 'border: 10px solid green; padding: 1em;',
'attributes[attributes]' => '',
'method' => '',
'action' => '',
'custom' => "'suffix': 'Form suffix TEST'\n'prefix': 'Form prefix TEST'",
];
$this
->drupalPostForm('/admin/structure/webform/manage/test_form_properties/settings/form', $edit, 'Save');
$this
->drupalGet('/webform/test_form_properties');
$this
->assertPattern('/Form prefix TEST<form /');
$this
->assertPattern('/<\\/form>\\s+Form suffix TEST/');
$this
->assertRaw('<form class="webform-submission-form webform-submission-add-form webform-submission-test-form-properties-form webform-submission-test-form-properties-add-form form--inline clearfix test-form-properties js-webform-details-toggle webform-details-toggle" style="border: 10px solid green; padding: 1em;" data-drupal-selector="webform-submission-test-form-properties-add-form" action="' . $base_path . 'webform/test_form_properties" method="post" id="webform-submission-test-form-properties-add-form" accept-charset="UTF-8">');
}
}