/** * @test */ public function willReturn404Responses() { $event = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent')->disableOriginalConstructor()->setMethods(['getException'])->getMock(); $event->expects($this->any())->method('getException')->willReturn(new NotFoundHttpException()); $this->exceptionListener->onKernelException($event); $response = $event->getResponse(); $this->assertSame(404, $response->getStatusCode()); }
/** * @test */ public function willLogExceptionsWithUnexpectedCodesAsCriticalErrors() { $sample = [4096, 777, 22, 5, 0]; foreach ($sample as $code) { $logger = $this->getMockForAbstractClass(LoggerInterface::class); $logger->expects($this->once())->method('log')->with(LogLevel::CRITICAL, $this->stringStartsWith('Internal Server Error')); /** @var LoggerInterface $logger */ $this->setLogger($this->exceptionListener, $logger); $this->codeProperty->setValue($this->exception, $code); $this->exceptionListener->onKernelException($this->event); } }