new GeneratedUrl())->
setGeneratedUrl('/test-route-1'
),
],
]);
$url =
new Url('test_route_1'
);
$url->
setUrlGenerator($this->urlGenerator
);
$expected_link_markup = '<a href="/test-route-1">Test</a>';
// Test ::generate().
$this->
assertSame($expected_link_markup,
(string) $this->linkGenerator->
generate('Test',
$url));
$generated_link =
$this->linkGenerator->
generate('Test',
$url);
$this->
assertSame($expected_link_markup,
(string) $generated_link->
getGeneratedLink());
$this->
assertInstanceOf('\Drupal\Core\Render\BubbleableMetadata',
$generated_link);
// Test ::generateFromLink().
$this->
expectDeprecation('\Drupal\Core\Utility\LinkGeneratorInterface::generateFromLink() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use \Drupal\Core\Utility\LinkGeneratorInterface::generate() instead. See https://www.drupal.org/node/3342992'
);
$link =
new Link('Test',
$url);
$this->
assertSame($expected_link_markup,
(string) $this->linkGenerator->
generateFromLink($link));
$generated_link =
$this->linkGenerator->
generateFromLink($link);
$this->
assertSame($expected_link_markup,
(string) $generated_link->
getGeneratedLink());
$this->
assertInstanceOf('\Drupal\Core\Render\BubbleableMetadata',
$generated_link);
}