WebformRenderingTest.php in Webform 8.5
File
tests/src/Functional/WebformRenderingTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional;
use Drupal\Core\Test\AssertMailTrait;
use Drupal\webform\Entity\Webform;
class WebformRenderingTest extends WebformBrowserTestBase {
use AssertMailTrait;
public static $modules = [
'filter',
'webform',
];
protected static $testWebforms = [
'test_rendering',
];
protected function setUp() {
parent::setUp();
$this
->createFilters();
$this
->drupalLogin($this->rootUser);
}
public function testRendering() {
$webform = Webform::load('test_rendering');
$this
->drupalPostForm('/webform/test_rendering', [], 'Preview');
$this
->assertRaw('submission <em>label</em> (&><#)');
$this
->assertRaw('{prefix}{default_value}{suffix}');
$this
->assertRaw('<label><em>textfield_markup</em></label>');
$this
->assertRaw('<em>{prefix}</em>{default_value}<em>{suffix}</em>');
$this
->assertRaw('<label>textfield_special_characters (&><#)</label>');
$this
->assertRaw('(&><#){default_value}(&><#)');
$this
->assertRaw('<p><em>{default_value}</em></p>');
$sid = $this
->postSubmission($webform);
$sent_emails = $this
->getMails();
$html_email = $sent_emails[0];
$text_email = $sent_emails[1];
$this
->assertEqual($html_email['subject'], 'submission label (&>');
$this
->assertEqual($html_email['params']['subject'], 'submission <em>label</em> (&><#)');
$this
->assertStringContainsString('<b>submission_label</b><br />submission <em>label</em> (&><#)<br /><br />', $html_email['params']['body']);
$this
->assertStringContainsString('<b>textfield_plain_text</b><br />{prefix}{default_value}{suffix}<br /><br />', $html_email['params']['body']);
$this
->assertStringContainsString('<b><em>textfield_markup</em></b><br /><em>{prefix}</em>{default_value}<em>{suffix}</em><br /><br />', $html_email['params']['body']);
$this
->assertStringContainsString('<b>textfield_special_characters (&><#)</b><br />(&><#){default_value}(&><#)<br /><br />', $html_email['params']['body']);
$this
->assertStringContainsString('<b>text_format_basic_html</b><br /><p><em>{default_value}</em></p><br /><br />', $html_email['params']['body']);
$this
->assertEqual($text_email['subject'], 'submission label (&>');
$this
->assertEqual($text_email['params']['subject'], 'submission <em>label</em> (&><#)');
$this
->assertStringContainsString('submission_label: submission <em>label</em> (&><#)', $text_email['params']['body']);
$this
->assertStringContainsString('textfield_plain_text: {prefix}{default_value}{suffix}', $text_email['params']['body']);
$this
->assertStringContainsString('textfield_markup: {prefix}{default_value}{suffix}', $text_email['params']['body']);
$this
->assertStringContainsString('textfield_special_characters (&>: (&>{default_value}(&>', $text_email['params']['body']);
$this
->assertStringContainsString('text_format_basic_html:', $text_email['params']['body']);
$this
->assertStringContainsString('/{default_value}/', $text_email['params']['body']);
$this
->drupalGet("admin/structure/webform/manage/test_rendering/submission/{$sid}");
$this
->assertRaw('<h1>submission <em>label</em> (&><#)</h1>');
}
}