You are here

protected function WebformAssertLegacyTrait::assertNoText in Webform 6.x

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

Passes if the page (with HTML stripped) does not 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.

3 calls to WebformAssertLegacyTrait::assertNoText()
WebformHandlerEmailMappingTest::testEmailMapping in tests/src/Functional/Handler/WebformHandlerEmailMappingTest.php
Test email mapping handler.
WebformLibrariesTest::testLibraries in tests/src/Functional/WebformLibrariesTest.php
Tests webform libraries.
WebformVariantElementTest::testVariantElement in tests/src/Functional/Variant/WebformVariantElementTest.php
Test variant element.

File

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

Class

WebformAssertLegacyTrait
Provides convenience methods for assertions in browser tests.

Namespace

Drupal\Tests\webform\Traits

Code

protected function assertNoText($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()
      ->responseNotContains($text);
  }
  else {
    $this
      ->assertTextHelper($text);
  }
}