function AcceptHeaderMatcherTest::testNoRouteFound

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

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

File

core/tests/Drupal/Tests/Core/Routing/AcceptHeaderMatcherTest.php, line 92

Class

AcceptHeaderMatcherTest
Confirm that the mime types partial matcher is functioning properly.

Namespace

Drupal\Tests\Core\Routing

Code

public function testNoRouteFound() : void {
    // Remove the sample routes that would match any method.
    $routes = $this->fixtures
        ->sampleRouteCollection();
    $routes->remove('route_a');
    $routes->remove('route_b');
    $routes->remove('route_c');
    $routes->remove('route_d');
    $request = Request::create('path/two', 'GET');
    $request->headers
        ->set('Accept', 'application/json, text/xml;q=0.9');
    $request->setRequestFormat('json');
    $this->expectException(NotAcceptableHttpException::class);
    $this->expectExceptionMessage('No route found for the specified formats application/json text/xml');
    $this->matcher
        ->filter($routes, $request);
}

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