Loading core/lib/Drupal/Core/Url.php +3 −3 Original line number Diff line number Diff line Loading @@ -588,7 +588,7 @@ public function getRouteName() { */ public function getRouteParameters() { if ($this->unrouted) { throw new \UnexpectedValueException('External URLs do not have internal route parameters.'); throw new \UnexpectedValueException($this->getUri() . ' has no corresponding route.'); } return $this->routeParameters; Loading @@ -607,7 +607,7 @@ public function getRouteParameters() { */ public function setRouteParameters($parameters) { if ($this->unrouted) { throw new \UnexpectedValueException('External URLs do not have route parameters.'); throw new \UnexpectedValueException($this->getUri() . ' has no corresponding route.'); } $this->routeParameters = $parameters; return $this; Loading @@ -628,7 +628,7 @@ public function setRouteParameters($parameters) { */ public function setRouteParameter($key, $value) { if ($this->unrouted) { throw new \UnexpectedValueException('External URLs do not have route parameters.'); throw new \UnexpectedValueException($this->getUri() . ' has no corresponding route.'); } $this->routeParameters[$key] = $value; return $this; Loading core/tests/Drupal/Tests/Core/UrlTest.php +25 −0 Original line number Diff line number Diff line Loading @@ -426,9 +426,34 @@ public function testGetRouteParameters($urls): void { public function testGetRouteParametersWithExternalUrl(): void { $url = Url::fromUri('http://example.com'); $this->expectException(\UnexpectedValueException::class); $this->expectExceptionMessage('http://example.com has no corresponding route.'); $url->getRouteParameters(); } /** * Tests the setRouteParameters() with an unrouted URL. * * @legacy-covers ::setRouteParameters */ public function testSetRouteParametersWithUnroutedUrl(): void { $url = Url::fromUri('https://example.com'); $this->expectException(\UnexpectedValueException::class); $this->expectExceptionMessage('https://example.com has no corresponding route.'); $url->setRouteParameters(['foo' => 'bar']); } /** * Tests the setRouteParameter() with an unrouted URL. * * @legacy-covers ::setRouteParameter */ public function testSetRouteParameterWithUnroutedUrl(): void { $url = Url::fromUri('https://example.com'); $this->expectException(\UnexpectedValueException::class); $this->expectExceptionMessage('https://example.com has no corresponding route.'); $url->setRouteParameter('foo', 'bar'); } /** * Tests the getOptions() method. * Loading Loading
core/lib/Drupal/Core/Url.php +3 −3 Original line number Diff line number Diff line Loading @@ -588,7 +588,7 @@ public function getRouteName() { */ public function getRouteParameters() { if ($this->unrouted) { throw new \UnexpectedValueException('External URLs do not have internal route parameters.'); throw new \UnexpectedValueException($this->getUri() . ' has no corresponding route.'); } return $this->routeParameters; Loading @@ -607,7 +607,7 @@ public function getRouteParameters() { */ public function setRouteParameters($parameters) { if ($this->unrouted) { throw new \UnexpectedValueException('External URLs do not have route parameters.'); throw new \UnexpectedValueException($this->getUri() . ' has no corresponding route.'); } $this->routeParameters = $parameters; return $this; Loading @@ -628,7 +628,7 @@ public function setRouteParameters($parameters) { */ public function setRouteParameter($key, $value) { if ($this->unrouted) { throw new \UnexpectedValueException('External URLs do not have route parameters.'); throw new \UnexpectedValueException($this->getUri() . ' has no corresponding route.'); } $this->routeParameters[$key] = $value; return $this; Loading
core/tests/Drupal/Tests/Core/UrlTest.php +25 −0 Original line number Diff line number Diff line Loading @@ -426,9 +426,34 @@ public function testGetRouteParameters($urls): void { public function testGetRouteParametersWithExternalUrl(): void { $url = Url::fromUri('http://example.com'); $this->expectException(\UnexpectedValueException::class); $this->expectExceptionMessage('http://example.com has no corresponding route.'); $url->getRouteParameters(); } /** * Tests the setRouteParameters() with an unrouted URL. * * @legacy-covers ::setRouteParameters */ public function testSetRouteParametersWithUnroutedUrl(): void { $url = Url::fromUri('https://example.com'); $this->expectException(\UnexpectedValueException::class); $this->expectExceptionMessage('https://example.com has no corresponding route.'); $url->setRouteParameters(['foo' => 'bar']); } /** * Tests the setRouteParameter() with an unrouted URL. * * @legacy-covers ::setRouteParameter */ public function testSetRouteParameterWithUnroutedUrl(): void { $url = Url::fromUri('https://example.com'); $this->expectException(\UnexpectedValueException::class); $this->expectExceptionMessage('https://example.com has no corresponding route.'); $url->setRouteParameter('foo', 'bar'); } /** * Tests the getOptions() method. * Loading