diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php index f4dc2df..c3af2db 100644 --- a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php +++ b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php @@ -538,6 +538,25 @@ public function testGenerateWithAlterHook() { } /** + * Tests whether rendering the same link twice works. + * + * This is a regression test for https://www.drupal.org/node/2842399. + */ + public function testGenerateTwice() { + $this->urlGenerator->expects($this->any()) + ->method('generateFromRoute') + ->will($this->returnValue((new GeneratedUrl())->setGeneratedUrl('/'))); + + $url = Url::fromRoute('', [], ['attributes' => ['class' => ['foo', 'bar']]]); + $url->setUrlGenerator($this->urlGenerator); + + $link = Link::fromTextAndUrl('text', $url); + $link->setLinkGenerator($this->linkGenerator); + $output = $link->toString() . $link->toString(); + $this->assertEquals('texttext', $output); + } + + /** * Checks that a link with certain properties exists in a given HTML snippet. * * @param array $properties