function UrlTest::testFromRouteMatch

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/UrlTest.php \Drupal\Tests\Core\UrlTest::testFromRouteMatch()
  2. 8.9.x core/tests/Drupal/Tests/Core/UrlTest.php \Drupal\Tests\Core\UrlTest::testFromRouteMatch()
  3. 11.x core/tests/Drupal/Tests/Core/UrlTest.php \Drupal\Tests\Core\UrlTest::testFromRouteMatch()

Tests the fromRouteMatch() method.

File

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

Class

UrlTest
@coversDefaultClass \Drupal\Core\Url[[api-linebreak]] @group UrlTest

Namespace

Drupal\Tests\Core

Code

public function testFromRouteMatch() : void {
  $route = new Route('/test-route/{foo}');
  $route_match = new RouteMatch('test_route', $route, [
    'foo' => (object) [
      1,
    ],
  ], [
    'foo' => 1,
  ]);
  $url = Url::fromRouteMatch($route_match);
  $this->assertSame('test_route', $url->getRouteName());
  $this->assertEquals([
    'foo' => '1',
  ], $url->getRouteParameters());
}

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