You are here

public function UrlTest::testUrlFromRequestInvalid in Drupal 8

Tests that an invalid request will thrown an exception.

@covers ::createFromRequest

File

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

Class

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

Namespace

Drupal\Tests\Core

Code

public function testUrlFromRequestInvalid() {
  $request = Request::create('/test-path');
  $this->router
    ->expects($this
    ->once())
    ->method('matchRequest')
    ->with($request)
    ->will($this
    ->throwException(new ResourceNotFoundException()));
  $this
    ->expectException(ResourceNotFoundException::class);
  Url::createFromRequest($request);
}