-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to test 'Internal Server Error' from a LocalWebTestCase #34
Comments
That's some very thorough integration testing. I haven't tried this, and I'm not entirely sure what is going on. What version of Slim are you using? |
I am using the V3. Actually I found the fix. In Replace // Invoke request
$app = $this->app;
$this->response = $app($this->request, $response); By // Process request
$app = $this->app;
$this->response = $app->process($this->request, $response); Therefore Slim would handle the exception in // Traverse middleware stack
try {
$response = $this->callMiddlewareStack($request, $response);
} catch (Exception $e) {
$response = $this->handleException($e, $request, $response);
} catch (Throwable $e) {
$response = $this->handlePhpError($e, $request, $response);
} I tested, the Could you please fix it in a new release ? |
@Starli0n Thanks for the report! If you have time, can you send a PR for this fix? I'd like to add you as a contributor. Thanks! |
Fix found in pull request #35. |
As a side note, the mentioned PR also fixed a problem I had with App Middleware not being executed. Thanks 👍 |
@Starli0n : I added a short release description on https://github.com/there4/slim-test-helpers/releases , feel free to edit it if you can phrase this better :) |
Hi,
I would like to test an 'Internal Server Error' from a LocalWebTestCase but I do not know how to do it.
First I added this error handler in SlimApp:
I added a specific route only for testing purpose:
In a test case I do:
But
$this->client->response
return null.My aim would be to test the message sent by the server defined in the error handler.
In a production environment, this route is working fine and I have the message 'Internal Server Error' in json.
http://localhost:8080/internalerror
Thanks for your help!
The text was updated successfully, but these errors were encountered: