function UrlTest::testSetRouteParametersWithUnroutedUrl

Tests the setRouteParameters() with an unrouted URL.

@legacy-covers ::setRouteParameters

File

core/tests/Drupal/Tests/Core/UrlTest.php, line 414

Class

UrlTest
Tests Drupal\Core\Url.

Namespace

Drupal\Tests\Core

Code

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',
  ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.