You are here

public function WebformHandlerSettingsTest::testSettingsHandler in Webform 8.5

Same name and namespace in other branches
  1. 6.x tests/src/Functional/Handler/WebformHandlerSettingsTest.php \Drupal\Tests\webform\Functional\Handler\WebformHandlerSettingsTest::testSettingsHandler()

Test settings handler.

File

tests/src/Functional/Handler/WebformHandlerSettingsTest.php, line 24

Class

WebformHandlerSettingsTest
Tests for settings webform handler functionality.

Namespace

Drupal\Tests\webform\Functional\Handler

Code

public function testSettingsHandler() {

  // NOTE: Using message indentation to make sure the message is matched
  // and not the input value.
  $message_indentation = '                    ';

  // Check custom save draft message.
  $edit = [
    'preview' => TRUE,
    'confirmation' => TRUE,
    'custom' => TRUE,
  ];
  $this
    ->drupalPostForm('/webform/test_handler_settings', $edit, 'Save Draft');
  $this
    ->assertRaw($message_indentation . '{Custom draft saved message}');

  // Check custom save load message.
  $this
    ->drupalGet('/webform/test_handler_settings');

  // NOTE: Adding indentation to make sure the message is matched and not input value.
  $this
    ->assertRaw($message_indentation . '{Custom draft loaded message}');

  // Check custom preview title and message.
  $this
    ->drupalPostForm('/webform/test_handler_settings', [], 'Preview');
  $this
    ->assertRaw('<li>{Custom preview message}</li>');
  $this
    ->assertRaw('<h1>{Custom preview title}</h1>');

  // Check custom confirmation title and message.
  $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>');

  // Check no custom save draft message.
  $edit = [
    'preview' => FALSE,
    'confirmation' => FALSE,
    'custom' => FALSE,
  ];
  $this
    ->drupalPostForm('/webform/test_handler_settings', $edit, 'Save Draft');
  $this
    ->assertNoRaw($message_indentation . '{Custom draft saved message}');

  // Check no custom save load message.
  $this
    ->drupalGet('/webform/test_handler_settings');
  $this
    ->assertNoRaw($message_indentation . '{Custom draft loaded message}');

  // Check no custom preview title and 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>');

  // Check no custom confirmation title and message.
  $this
    ->drupalPostForm('/webform/test_handler_settings', [], 'Submit');
  $this
    ->assertNoRaw('{Custom confirmation title}');
  $this
    ->assertNoRaw('{Custom confirmation message}');
}