function DrupalTest::testL
Tests the l() method.
@covers ::l
@group legacy
@expectedDeprecation \Drupal::l() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Link::fromTextAndUrl() instead. See https://www.drupal.org/node/2614344
See also
\Drupal\Core\Utility\LinkGeneratorInterface::generate()
File
-
core/
tests/ Drupal/ Tests/ Core/ DrupalTest.php, line 402
Class
- DrupalTest
- Tests the Drupal class.
Namespace
Drupal\Tests\CoreCode
public function testL() {
$route_parameters = [
'test_parameter' => 'test',
];
$options = [
'test_option' => 'test',
];
$generator = $this->createMock('Drupal\\Core\\Utility\\LinkGeneratorInterface');
$url = new Url('test_route', $route_parameters, $options);
$generator->expects($this->once())
->method('generate')
->with('Test title', $url)
->will($this->returnValue('link_html_string'));
$this->setMockContainerService('link_generator', $generator);
$this->assertInternalType('string', \Drupal::l('Test title', $url));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.