function UrlTest::testFromRouteMatch

Same name 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 @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.