/** * @param GetResponseForExceptionEvent $event */ public function onKernelException(GetResponseForExceptionEvent $event) { if (!$this->matcher->matches($event->getRequest())) { return; } $this->exceptionListener->onKernelException($event); }
public function testListenerIgnoresUnmatchedContentTypes() { $transformer = $this->prophesize('Alchemy\\Rest\\Response\\ExceptionTransformer'); $exception = new \Exception('test', 12); $listener = new ExceptionListener(new ContentTypeMatcher(), $transformer->reveal(), array('text/plain')); $event = $this->getControllerExceptionEvent($exception); $event->getRequest()->headers->set('Accept', 'application/json'); $listener->onKernelException($event); $this->assertNull($event->getResponse()); }