|
8 | 8 | use ErrorHeroModule\Listener\Mvc; |
9 | 9 | use Exception; |
10 | 10 | use Kahlan\Plugin\Double; |
11 | | -use Kahlan\Plugin\Quit; |
12 | | -use Kahlan\QuitException; |
13 | | -use Laminas\Console\Console; |
14 | | -use Laminas\Console\Request as ConsoleRequest; |
15 | 11 | use Laminas\Db\Adapter\Adapter; |
16 | 12 | use Laminas\Db\Adapter\AdapterInterface; |
17 | 13 | use Laminas\EventManager\EventManagerInterface; |
|
166 | 162 |
|
167 | 163 | }); |
168 | 164 |
|
169 | | - it('call logging->handleErrorException() with default console error message if $e->getParam("exception") and display_errors = 0', function (): void { |
| 165 | + it('call logging->handleErrorException() with default view error if $e->getParam("exception") and display_errors = 0', function (): void { |
170 | 166 |
|
171 | | - Console::overrideIsConsole(true); |
172 | | - |
173 | | - Quit::disable(); |
174 | | - $exception = new Exception('message'); |
175 | | - |
176 | | - $mvcEvent = Double::instance(['extends' => MvcEvent::class, 'methods' => '__construct']); |
177 | | - allow($mvcEvent)->toReceive('getParam')->andReturn($exception); |
178 | | - $request = new ConsoleRequest(); |
179 | | - allow($mvcEvent)->toReceive('getRequest')->andReturn($request); |
180 | | - allow($this->logging)->toReceive('handleErrorException')->with($exception, $request); |
181 | | - |
182 | | - $listener = new Mvc( |
183 | | - $this->config, |
184 | | - $this->logging, |
185 | | - $this->renderer |
186 | | - ); |
187 | | - |
188 | | - \ob_start(); |
189 | | - $closure = function () use ($listener, $mvcEvent): void { |
190 | | - $listener->exceptionError($mvcEvent); |
191 | | - }; |
192 | | - expect($closure)->toThrow(new QuitException('Exit statement occurred', -1)); |
193 | | - $content = \ob_get_clean(); |
194 | | - |
195 | | - expect($content)->toContain('|We have encountered a problem'); |
196 | | - }); |
197 | | - |
198 | | - it('call logging->handleErrorException() with default view error if $e->getParam("exception") and display_errors = 0 and not a console', function (): void { |
199 | | - |
200 | | - Console::overrideIsConsole(false); |
201 | 167 | $exception = new Exception('message'); |
202 | 168 |
|
203 | 169 | $mvcEvent = Double::instance(['extends' => MvcEvent::class, 'methods' => '__construct']); |
|
0 commit comments