diff --git a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php index f81e689..247fdad 100644 --- a/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php +++ b/core/tests/Drupal/Tests/Core/Utility/LinkGeneratorTest.php @@ -121,7 +121,7 @@ public function testGenerateHrefs($route_name, array $parameters, $absolute, $ur } /** - * Tests the generateFromUrl() method. + * Tests the generateFromUrl() method with a route. * * @covers ::generateFromUrl() */ @@ -131,7 +131,7 @@ public function testGenerateFromUrl() { ->with('test_route_1', array(), array('fragment' => 'the-fragment') + $this->defaultOptions) ->will($this->returnValue('/test-route-1#the-fragment')); - $this->moduleHandler->expects($this->exactly(2)) + $this->moduleHandler->expects($this->once()) ->method('alter') ->with('link', $this->isType('array')); @@ -146,12 +146,26 @@ public function testGenerateFromUrl() { ), 'content' => 'Test', ), $result); + } + /** + * Tests the generateFromUrl() method with an external URL. + * + * The set_active_class option is set to TRUE to insure this does not cause + * an error with an external URL. + * + * @covers ::generateFromUrl() + */ + public function testGenerateFromUrlExternal() { $this->urlGenerator->expects($this->once()) ->method('generateFromPath') ->with('http://drupal.org', array('external' => TRUE, 'set_active_class' => TRUE) + $this->defaultOptions) ->will($this->returnValue('http://drupal.org')); + $this->moduleHandler->expects($this->once()) + ->method('alter') + ->with('link', $this->isType('array')); + $url = Url::createFromPath('http://drupal.org'); $url->setUrlGenerator($this->urlGenerator); $url->setOption('set_active_class', TRUE);