/** * Confirms that the matcher throws an exception for no-route. * * @expectedException \Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException * @expectedExceptionMessage No route found that matches the Content-Type header. */ public function testNoRouteFound() { $matcher = new ContentTypeHeaderMatcher(); $routes = $this->fixtures->contentRouteCollection(); $request = Request::create('path/two', 'POST'); $request->headers->set('Content-type', 'application/hal+json'); $matcher->filter($routes, $request); $this->fail('No exception was thrown.'); }
/** * Confirms that the matcher throws an exception for missing request header. * * @covers ::filter */ public function testContentTypeRequestHeaderMissing() { $matcher = new ContentTypeHeaderMatcher(); $routes = $this->fixtures->contentRouteCollection(); $request = Request::create('path/two', 'POST'); // Delete all request headers that Request::create() sets by default. $request->headers = new ParameterBag(); $this->setExpectedException(UnsupportedMediaTypeHttpException::class, 'No "Content-Type" request header specified'); $matcher->filter($routes, $request); }