function ContentTypeHeaderMatcherTest::testNoRouteFound

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Routing/ContentTypeHeaderMatcherTest.php \Drupal\Tests\Core\Routing\ContentTypeHeaderMatcherTest::testNoRouteFound()
  2. 8.9.x core/tests/Drupal/Tests/Core/Routing/ContentTypeHeaderMatcherTest.php \Drupal\Tests\Core\Routing\ContentTypeHeaderMatcherTest::testNoRouteFound()
  3. 11.x core/tests/Drupal/Tests/Core/Routing/ContentTypeHeaderMatcherTest.php \Drupal\Tests\Core\Routing\ContentTypeHeaderMatcherTest::testNoRouteFound()

Confirms that the matcher throws an exception for no-route.

@covers ::filter

File

core/tests/Drupal/Tests/Core/Routing/ContentTypeHeaderMatcherTest.php, line 111

Class

ContentTypeHeaderMatcherTest
Confirm that the content types partial matcher is functioning properly.

Namespace

Drupal\Tests\Core\Routing

Code

public function testNoRouteFound() : void {
    $matcher = new ContentTypeHeaderMatcher();
    $routes = $this->fixtures
        ->contentRouteCollection();
    $request = Request::create('path/two', 'POST');
    $request->headers
        ->set('Content-type', 'text/html');
    $this->expectException(UnsupportedMediaTypeHttpException::class);
    $this->expectExceptionMessage('No route found that matches "Content-Type: text/html"');
    $matcher->filter($routes, $request);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.