You are here

public function SafeMarkupTest::testIsSafe in Drupal 8

Tests SafeMarkup::isSafe() with different objects.

@covers ::isSafe @expectedDeprecation SafeMarkup::isSafe() is scheduled for removal in Drupal 9.0.0. Instead, you should just check if a variable is an instance of \Drupal\Component\Render\MarkupInterface. See https://www.drupal.org/node/2549395.

File

core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php, line 41
Contains \Drupal\Tests\Component\Utility\SafeMarkupTest.

Class

SafeMarkupTest
Tests marking strings as safe.

Namespace

Drupal\Tests\Component\Utility

Code

public function testIsSafe() {
  $safe_string = $this
    ->getMockBuilder('\\Drupal\\Component\\Render\\MarkupInterface')
    ->getMock();
  $this
    ->assertTrue(SafeMarkup::isSafe($safe_string));
  $string_object = new SafeMarkupTestString('test');
  $this
    ->assertFalse(SafeMarkup::isSafe($string_object));
}