function TwigSandboxTest::testUrlSafeMethods
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Template/TwigSandboxTest.php \Drupal\Tests\Core\Template\TwigSandboxTest::testUrlSafeMethods()
- 8.9.x core/tests/Drupal/Tests/Core/Template/TwigSandboxTest.php \Drupal\Tests\Core\Template\TwigSandboxTest::testUrlSafeMethods()
- 10 core/tests/Drupal/Tests/Core/Template/TwigSandboxTest.php \Drupal\Tests\Core\Template\TwigSandboxTest::testUrlSafeMethods()
Tests that safe methods inside Url objects can be called.
File
-
core/
tests/ Drupal/ Tests/ Core/ Template/ TwigSandboxTest.php, line 147
Class
- TwigSandboxTest
- Tests the twig sandbox policy.
Namespace
Drupal\Tests\Core\TemplateCode
public function testUrlSafeMethods() : void {
$url = $this->getMockBuilder('Drupal\\Core\\Url')
->disableOriginalConstructor()
->getMock();
$url->expects($this->once())
->method('toString')
->willReturn('http://kittens.cat/are/cute');
$result = $this->twig
->render('{{ url.toString }}', [
'url' => $url,
]);
$this->assertEquals('http://kittens.cat/are/cute', $result, 'Sandbox policy allows toString() to be called.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.