core/lib/Drupal/Core/Link.php | 4 --- core/lib/Drupal/Core/Utility/LinkGenerator.php | 2 +- .../Tests/Core/Utility/LinkGeneratorTest.php | 40 +++++----------------- 3 files changed, 9 insertions(+), 37 deletions(-) diff --git a/core/lib/Drupal/Core/Link.php b/core/lib/Drupal/Core/Link.php index 8db6591..f739ad1 100644 --- a/core/lib/Drupal/Core/Link.php +++ b/core/lib/Drupal/Core/Link.php @@ -140,10 +140,6 @@ public function setUrl(Url $url) { /** * Generates the HTML for this Link object. * - * @param bool $collect_bubbleable_metadata - * (optional) Defaults to FALSE. When TRUE, both the generated link and its - * associated bubbleable metadata are returned. - * * @return \Drupal\Core\GeneratedLink * The link HTML markup. * diff --git a/core/lib/Drupal/Core/Utility/LinkGenerator.php b/core/lib/Drupal/Core/Utility/LinkGenerator.php index a3d991a..4527f77 100644 --- a/core/lib/Drupal/Core/Utility/LinkGenerator.php +++ b/core/lib/Drupal/Core/Utility/LinkGenerator.php @@ -155,7 +155,7 @@ public function generate($text, Url $url) { unset($variables['options']['attributes']); $url->setOptions($variables['options']); - // External urls can not have cacheable metadata. + // External URLs can not have cacheable metadata. if ($url->isExternal()) { $generated_link = new GeneratedLink(); $attributes['href'] = $url->toString(FALSE); diff --git a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php index eb296cf..05f1af1 100644 --- a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php +++ b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php @@ -112,10 +112,7 @@ public function testGenerateHrefs($route_name, array $parameters, $absolute, $ex $this->urlGenerator->expects($this->once()) ->method('generateFromRoute') ->with($route_name, $parameters, array('absolute' => $absolute) + $this->defaultOptions) - ->willReturnCallback(function() use ($expected_url) { - $url = new GeneratedUrl(); - return $url->setGeneratedUrl($expected_url); - }); + ->willReturn((new GeneratedUrl())->setGeneratedUrl($expected_url)); $this->moduleHandler->expects($this->once()) ->method('alter'); @@ -136,10 +133,7 @@ public function testGenerate() { $this->urlGenerator->expects($this->once()) ->method('generateFromRoute') ->with('test_route_1', array(), array('fragment' => 'the-fragment') + $this->defaultOptions) - ->willReturnCallback(function() { - $url = new GeneratedUrl(); - return $url->setGeneratedUrl('/test-route-1#the-fragment'); - }); + ->willReturn((new GeneratedUrl())->setGeneratedUrl('/test-route-1#the-fragment')); $this->moduleHandler->expects($this->once()) ->method('alter') @@ -259,10 +253,7 @@ public function testGenerateQuery() { $this->urlGenerator->expects($this->once()) ->method('generateFromRoute') ->with('test_route_1', array(), array('query' => array('test' => 'value')) + $this->defaultOptions) - ->willReturnCallback(function() { - $url = new GeneratedUrl(); - return $url->setGeneratedUrl('/test-route-1?test=value'); - }); + ->willReturn((new GeneratedUrl())->setGeneratedUrl('/test-route-1?test=value')); $url = new Url('test_route_1', array(), array( 'query' => array('test' => 'value'), @@ -285,10 +276,7 @@ public function testGenerateParametersAsQuery() { $this->urlGenerator->expects($this->once()) ->method('generateFromRoute') ->with('test_route_1', array('test' => 'value'), $this->defaultOptions) - ->willReturnCallback(function() { - $url = new GeneratedUrl(); - return $url->setGeneratedUrl('/test-route-1?test=value'); - }); + ->willReturn((new GeneratedUrl())->setGeneratedUrl('/test-route-1?test=value')); $url = new Url('test_route_1', array('test' => 'value'), array()); $url->setUrlGenerator($this->urlGenerator); @@ -309,10 +297,7 @@ public function testGenerateOptions() { $this->urlGenerator->expects($this->once()) ->method('generateFromRoute') ->with('test_route_1', array(), array('key' => 'value') + $this->defaultOptions) - ->willReturnCallback(function() { - $url = new GeneratedUrl(); - return $url->setGeneratedUrl('/test-route-1?test=value'); - }); + ->willReturn((new GeneratedUrl())->setGeneratedUrl('/test-route-1?test=value')); $url = new Url('test_route_1', array(), array( 'key' => 'value', )); @@ -334,10 +319,7 @@ public function testGenerateXss() { $this->urlGenerator->expects($this->once()) ->method('generateFromRoute') ->with('test_route_4', array(), $this->defaultOptions) - ->willReturnCallback(function() { - $url = new GeneratedUrl(); - return $url->setGeneratedUrl('/test-route-4'); - }); + ->willReturn((new GeneratedUrl())->setGeneratedUrl('/test-route-4')); // Test that HTML link text is escaped by default. $url = new Url('test_route_4'); @@ -355,17 +337,11 @@ public function testGenerateWithHtml() { $this->urlGenerator->expects($this->at(0)) ->method('generateFromRoute') ->with('test_route_5', array(), $this->defaultOptions) - ->willReturnCallback(function() { - $url = new GeneratedUrl(); - return $url->setGeneratedUrl('/test-route-5'); - }); + ->willReturn((new GeneratedUrl())->setGeneratedUrl('/test-route-5')); $this->urlGenerator->expects($this->at(1)) ->method('generateFromRoute') ->with('test_route_5', array(), $this->defaultOptions) - ->willReturnCallback(function() { - $url = new GeneratedUrl(); - return $url->setGeneratedUrl('/test-route-5'); - }); + ->willReturn((new GeneratedUrl())->setGeneratedUrl('/test-route-5')); // Test that HTML tags are stripped from the 'title' attribute. $url = new Url('test_route_5', array(), array(