| @@ 99-126 (lines=28) @@ | ||
| 96 | $this->exceptionListener = new ExceptionListener($errorResponseFactory, $logRefBuilder, $this->logger); |
|
| 97 | } |
|
| 98 | ||
| 99 | public function testWillNotHandleIfNoDocumentUriInAttributesAndNotHttpException() |
|
| 100 | { |
|
| 101 | $event = $this |
|
| 102 | ->getMockBuilder(GetResponseForExceptionEvent::class) |
|
| 103 | ->disableOriginalConstructor() |
|
| 104 | ->setMethods(['getException', 'getRequest', 'setResponse']) |
|
| 105 | ->getMock(); |
|
| 106 | ||
| 107 | $event |
|
| 108 | ->expects($this->any()) |
|
| 109 | ->method('getException') |
|
| 110 | ->willReturn(new \Exception("Mary had a little lamb")) |
|
| 111 | ; |
|
| 112 | ||
| 113 | $event |
|
| 114 | ->expects($this->any()) |
|
| 115 | ->method('getRequest') |
|
| 116 | ->willReturn(new Request()) |
|
| 117 | ; |
|
| 118 | ||
| 119 | $event |
|
| 120 | ->expects($this->never()) |
|
| 121 | ->method('setResponse') |
|
| 122 | ; |
|
| 123 | ||
| 124 | /** @var GetResponseForExceptionEvent $event */ |
|
| 125 | $this->exceptionListener->onKernelException($event); |
|
| 126 | } |
|
| 127 | ||
| 128 | public function testWillHandleIfNoDocumentUriInAttributesButHttpException() |
|
| 129 | { |
|
| @@ 128-155 (lines=28) @@ | ||
| 125 | $this->exceptionListener->onKernelException($event); |
|
| 126 | } |
|
| 127 | ||
| 128 | public function testWillHandleIfNoDocumentUriInAttributesButHttpException() |
|
| 129 | { |
|
| 130 | $event = $this |
|
| 131 | ->getMockBuilder(GetResponseForExceptionEvent::class) |
|
| 132 | ->disableOriginalConstructor() |
|
| 133 | ->setMethods(['getException', 'getRequest', 'setResponse']) |
|
| 134 | ->getMock(); |
|
| 135 | ||
| 136 | $event |
|
| 137 | ->expects($this->any()) |
|
| 138 | ->method('getException') |
|
| 139 | ->willReturn(new NotFoundHttpException()) |
|
| 140 | ; |
|
| 141 | ||
| 142 | $event |
|
| 143 | ->expects($this->any()) |
|
| 144 | ->method('getRequest') |
|
| 145 | ->willReturn(new Request()) |
|
| 146 | ; |
|
| 147 | ||
| 148 | $event |
|
| 149 | ->expects($this->once()) |
|
| 150 | ->method('setResponse') |
|
| 151 | ; |
|
| 152 | ||
| 153 | /** @var GetResponseForExceptionEvent $event */ |
|
| 154 | $this->exceptionListener->onKernelException($event); |
|
| 155 | } |
|
| 156 | ||
| 157 | public function testWillLogExceptionsWith4xxCodesAsBadRequestNotices() |
|
| 158 | { |
|