-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
595f756
commit 20cfdbb
Showing
6 changed files
with
57 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
tests/Integration/ErrorHandler/NonFatalErrorHandlerMiddlewareTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace App\Test\Integration\ErrorHandler; | ||
|
||
use App\Test\Trait\AppTestTrait; | ||
use PHPUnit\Framework\TestCase; | ||
use TestTraits\Trait\HttpTestTrait; | ||
|
||
class NonFatalErrorHandlerMiddlewareTest extends TestCase | ||
{ | ||
use AppTestTrait; | ||
use HttpTestTrait; | ||
|
||
/** | ||
* Test that when a non-fatal error occurs, the NonFatalErrorHandlerMiddleware | ||
* makes an ErrorException. This is to make the app "exception-heavy" | ||
* and display a proper stack trace and error page in development. | ||
* Documentation: https://github.com/samuelgfeller/slim-example-project/wiki/Error-Handling. | ||
* | ||
* @return void | ||
*/ | ||
public function testNonFatalErrorHandler(): void | ||
{ | ||
// Add a route that triggers a non-fatal error | ||
$this->app->get('/error', function ($request, $response, $args) { | ||
// This will trigger a PHP notice because $undefinedVar is not defined | ||
/** @phpstan-ignore-next-line */ | ||
echo $undefinedVar; | ||
|
||
return $response; | ||
}); | ||
|
||
$request = $this->createRequest('GET', '/error'); | ||
|
||
// Expect that an ErrorException is thrown | ||
$this->expectException(\ErrorException::class); | ||
$this->expectExceptionMessage('Undefined variable $undefinedVar'); | ||
|
||
// Process the request through the application | ||
$this->app->handle($request); | ||
} | ||
} |