You are here

public function WebformElementMarkupTest::testMarkup in Webform 6.x

Same name and namespace in other branches
  1. 8.5 tests/src/Functional/Element/WebformElementMarkupTest.php \Drupal\Tests\webform\Functional\Element\WebformElementMarkupTest::testMarkup()

Test markup element.

File

tests/src/Functional/Element/WebformElementMarkupTest.php, line 29

Class

WebformElementMarkupTest
Tests for markup element.

Namespace

Drupal\Tests\webform\Functional\Element

Code

public function testMarkup() {

  // Check markup display on form.
  $this
    ->drupalGet('/webform/test_element_markup');
  $this
    ->assertCssSelect('.js-form-item-markup.form-item-markup.form-no-label');
  $this
    ->assertRaw('<p>This is normal markup</p>');
  $this
    ->assertRaw('<p>This is only displayed on the form view.</p>');
  $this
    ->assertNoRaw('<p>This is only displayed on the submission view.</p>');
  $this
    ->assertRaw('<p>This is displayed on the both the form and submission view.</p>');
  $this
    ->assertRaw('<p>This is displayed on the both the form and submission view.</p>');

  // Check markup alter via preprocessing.
  // @see webform_test_markup_preprocess_webform_html_editor_markup()
  $this
    ->drupalGet('/webform/test_element_markup');
  $this
    ->assertNoRaw('<p>Alter this markup.</p>');
  $this
    ->assertRaw('<p><em>Alter this markup.</em> <strong>This markup was altered.</strong></p>');

  // Check markup display on view.
  $this
    ->drupalPostForm('/webform/test_element_markup', [], 'Preview');
  $this
    ->assertNoRaw('<p>This is normal markup</p>');
  $this
    ->assertNoRaw('<p>This is only displayed on the form view.</p>');
  $this
    ->assertRaw('<p>This is only displayed on the submission view.</p>');
  $this
    ->assertRaw('<p>This is displayed on the both the form and submission view.</p>');
}