You are here

public function BrowserTestBaseTest::testAssertNoText in Drupal 9

Tests deprecated assertNoText.

@group legacy

File

core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php, line 335

Class

BrowserTestBaseTest
Tests BrowserTestBase functionality.

Namespace

Drupal\FunctionalTests

Code

public function testAssertNoText() {
  $this
    ->expectDeprecation('AssertLegacyTrait::assertNoText() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseNotContains() or $this->assertSession()->pageTextNotContains() instead. See https://www.drupal.org/node/3129738');
  $this
    ->expectDeprecation('Calling AssertLegacyTrait::assertNoText() with more than one argument is deprecated in drupal:8.2.0 and the method is removed from drupal:10.0.0. Use $this->assertSession()->responseNotContains() or $this->assertSession()->pageTextNotContains() instead. See https://www.drupal.org/node/3129738');
  $this
    ->drupalGet('test-encoded');
  $dangerous = 'Bad html <script>alert(123);</script>';
  $this
    ->assertNoText($dangerous, 'Dangerous text should not be present.');
}