function BrowserTestBaseTest::testAssertText
Tests deprecated assertText.
@group legacy
File
-
core/
tests/ Drupal/ FunctionalTests/ BrowserTestBaseTest.php, line 322
Class
- BrowserTestBaseTest
- Tests BrowserTestBase functionality.
Namespace
Drupal\FunctionalTestsCode
public function testAssertText() {
$this->expectDeprecation('AssertLegacyTrait::assertText() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseContains() or $this->assertSession()->pageTextContains() instead. See https://www.drupal.org/node/3129738');
$this->expectDeprecation('Calling AssertLegacyTrait::assertText() 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()->responseContains() or $this->assertSession()->pageTextContains() instead. See https://www.drupal.org/node/3129738');
$this->drupalGet('test-encoded');
$dangerous = 'Bad html <script>alert(123);</script>';
$this->assertText(Html::escape($dangerous), 'Sanitized text should be present.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.