You are here

protected function WebformAssertLegacyTrait::assertText in Webform 6.x

Same name and namespace in other branches
  1. 8.5 tests/src/Traits/WebformAssertLegacyTrait.php \Drupal\Tests\webform\Traits\WebformAssertLegacyTrait::assertText()

Passes if the page (with HTML stripped) contains the text.

Note that stripping HTML tags also removes their attributes, such as the values of text fields.

Parameters

string $text: Plain text to look for.

4 calls to WebformAssertLegacyTrait::assertText()
WebformHandlerEmailMappingTest::testEmailMapping in tests/src/Functional/Handler/WebformHandlerEmailMappingTest.php
Test email mapping handler.
WebformScheduledEmailTest::testWebformScheduledEmail in modules/webform_scheduled_email/tests/src/Functional/WebformScheduledEmailTest.php
Tests webform schedule email handler.
WebformVariantElementTest::testVariantElement in tests/src/Functional/Variant/WebformVariantElementTest.php
Test variant element.
WebformWizardAdvancedTest::testAdvancedWizard in tests/src/Functional/Wizard/WebformWizardAdvancedTest.php
Test webform advanced wizard.

File

tests/src/Traits/WebformAssertLegacyTrait.php, line 107

Class

WebformAssertLegacyTrait
Provides convenience methods for assertions in browser tests.

Namespace

Drupal\Tests\webform\Traits

Code

protected function assertText($text) {

  // Cast MarkupInterface to string.
  $text = (string) $text;
  $content_type = $this
    ->getSession()
    ->getResponseHeader('Content-type');

  // In case of a Non-HTML response (example: XML) check the original
  // response.
  if (strpos($content_type, 'html') === FALSE) {
    $this
      ->assertSession()
      ->responseContains($text);
  }
  else {
    $this
      ->assertTextHelper($text, FALSE);
  }
}