You are here

public function SafeMarkupTest::testCheckPlain in Drupal 8

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
Contains \Drupal\Tests\Component\Utility\SafeMarkupTest.

Class

SafeMarkupTest
Tests marking strings as safe.

Namespace

Drupal\Tests\Component\Utility

Code

public function testCheckPlain($text, $expected, $message) {
  $result = SafeMarkup::checkPlain($text);
  $this
    ->assertInstanceOf(HtmlEscapedText::class, $result);
  $this
    ->assertEquals($expected, $result, $message);
}