function SafeMarkupTest::testIsSafe

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

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));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.