You are here

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

Tests that an invalid request will thrown an exception.

@covers ::createFromRequest

@expectedException \Symfony\Component\Routing\Exception\ResourceNotFoundException

File

core/tests/Drupal/Tests/Core/UrlTest.php, line 286
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
    ->assertNull(Url::createFromRequest($request));
}