You are here

public function UrlTest::testFromRoutedPathWithInvalidRoute 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::testFromRoutedPathWithInvalidRoute()

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

@covers ::fromUri

File

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

Class

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

Namespace

Drupal\Tests\Core

Code

public function testFromRoutedPathWithInvalidRoute() {
  $this->pathValidator
    ->expects($this
    ->once())
    ->method('getUrlIfValidWithoutAccessCheck')
    ->with('invalid-path')
    ->willReturn(FALSE);
  $url = Url::fromUri('internal:/invalid-path');
  $this
    ->assertSame(FALSE, $url
    ->isRouted());
  $this
    ->assertSame('base:invalid-path', $url
    ->getUri());
}