public function AcceptHeaderMatcherTest::testNoRouteFound in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Routing/AcceptHeaderMatcherTest.php \Drupal\Tests\Core\Routing\AcceptHeaderMatcherTest::testNoRouteFound()
- 9 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 90
Class
- AcceptHeaderMatcherTest
- Confirm that the mime types partial matcher is functioning properly.
Namespace
Drupal\Tests\Core\RoutingCode
public function testNoRouteFound() {
// 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);
}