Skip to content
Snippets Groups Projects
Commit 338c7914 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2350507 by hussainweb, hctom, jbrown: Fixed \Drupal\Core\Url has no...

Issue #2350507 by hussainweb, hctom, jbrown: Fixed \Drupal\Core\Url has no __toString() magic method.
parent ca4a7b82
No related branches found
No related tags found
No related merge requests found
......@@ -451,6 +451,13 @@ public function toString() {
return $this->urlGenerator()->generateFromRoute($this->getRouteName(), $this->getRouteParameters(), $this->getOptions());
}
/**
* {@inheritdoc}
*/
public function __toString() {
return $this->toString();
}
/**
* Returns all the information about the route.
*
......
......@@ -234,6 +234,24 @@ public function testToString($urls) {
}
}
/**
* Tests the __toString() method.
*
* @param \Drupal\Core\Url[] $urls
* An array of Url objects.
*
* @depends testUrlFromRequest
*
* @covers ::__toString
*/
public function testMagicToString($urls) {
foreach ($urls as $index => $url) {
$url->setUrlGenerator(\Drupal::urlGenerator());
$path = array_pop($this->map[$index]);
$this->assertSame($path, (string) $url);
}
}
/**
* Tests the toArray() method.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment