function SafeMarkupTest::testCheckPlain
Tests SafeMarkup::checkPlain().
@dataProvider providerCheckPlain @covers ::checkPlain @expectedDeprecation SafeMarkup::checkPlain() is scheduled for removal in Drupal 9.0.0. Rely on Twig's auto-escaping feature, or use the #plain_text key when constructing a render array that contains plain text in order to use the renderer's auto-escaping feature. If neither of these are possible, \Drupal\Component\Utility\Html::escape() can be used in places where explicit escaping is needed. See https://www.drupal.org/node/2549395.
Parameters
string $text: The text to provide to SafeMarkup::checkPlain().
string $expected: The expected output from the function.
string $message: The message to provide as output for the test.
File
-
core/
tests/ Drupal/ Tests/ Component/ Utility/ SafeMarkupTest.php, line 62
Class
- SafeMarkupTest
- Tests marking strings as safe.
Namespace
Drupal\Tests\Component\UtilityCode
public function testCheckPlain($text, $expected, $message) {
$result = SafeMarkup::checkPlain($text);
$this->assertInstanceOf(HtmlEscapedText::class, $result);
$this->assertEquals($expected, $result, $message);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.