WebformHandlerSettingsTest.php in Webform 8.5
File
tests/src/Functional/Handler/WebformHandlerSettingsTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional\Handler;
use Drupal\Tests\webform\Functional\WebformBrowserTestBase;
class WebformHandlerSettingsTest extends WebformBrowserTestBase {
protected static $testWebforms = [
'test_handler_settings',
];
public function testSettingsHandler() {
$message_indentation = ' ';
$edit = [
'preview' => TRUE,
'confirmation' => TRUE,
'custom' => TRUE,
];
$this
->drupalPostForm('/webform/test_handler_settings', $edit, 'Save Draft');
$this
->assertRaw($message_indentation . '{Custom draft saved message}');
$this
->drupalGet('/webform/test_handler_settings');
$this
->assertRaw($message_indentation . '{Custom draft loaded message}');
$this
->drupalPostForm('/webform/test_handler_settings', [], 'Preview');
$this
->assertRaw('<li>{Custom preview message}</li>');
$this
->assertRaw('<h1>{Custom preview title}</h1>');
$this
->drupalPostForm('/webform/test_handler_settings', [], 'Submit');
$this
->assertRaw('<h1>{Custom confirmation title}</h1>');
$this
->assertRaw('<div class="webform-confirmation__message">{Custom confirmation message}</div>');
$edit = [
'preview' => FALSE,
'confirmation' => FALSE,
'custom' => FALSE,
];
$this
->drupalPostForm('/webform/test_handler_settings', $edit, 'Save Draft');
$this
->assertNoRaw($message_indentation . '{Custom draft saved message}');
$this
->drupalGet('/webform/test_handler_settings');
$this
->assertNoRaw($message_indentation . '{Custom draft loaded message}');
$this
->drupalPostForm('/webform/test_handler_settings', [], 'Preview');
$this
->assertNoRaw('<h1>{Custom confirmation title}</h1>');
$this
->assertNoRaw('<div class="webform-confirmation__message">{Custom confirmation message}</div>');
$this
->drupalPostForm('/webform/test_handler_settings', [], 'Submit');
$this
->assertNoRaw('{Custom confirmation title}');
$this
->assertNoRaw('{Custom confirmation message}');
}
}