You are here

public function UrlTest::testFromRoutedPathWithValidRoute in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/UrlTest.php \Drupal\Tests\Core\UrlTest::testFromRoutedPathWithValidRoute()

Tests fromUri() method with user-entered path matching a valid route.

@covers ::fromUri

File

core/tests/Drupal/Tests/Core/UrlTest.php, line 245
Contains \Drupal\Tests\Core\UrlTest.

Class

UrlTest
@coversDefaultClass \Drupal\Core\Url @group UrlTest

Namespace

Drupal\Tests\Core

Code

public function testFromRoutedPathWithValidRoute() {
  $url = Url::fromRoute('test_route');
  $this->pathValidator
    ->expects($this
    ->once())
    ->method('getUrlIfValidWithoutAccessCheck')
    ->with('valid-path')
    ->willReturn($url);
  $result_url = Url::fromUri('internal:/valid-path');
  $this
    ->assertSame($url, $result_url);
}