Skip to content

Instantly share code, notes, and snippets.

@viralsolani
Last active May 9, 2017 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viralsolani/57341bd32048fec4e11bd90988ee6322 to your computer and use it in GitHub Desktop.
Save viralsolani/57341bd32048fec4e11bd90988ee6322 to your computer and use it in GitHub Desktop.
Laravel - TestCase.php
<?php
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
protected function setUp()
{
parent::setUp();
$this->disableExceptionHandling();
}
// Superb tip by, @adamwathan.
protected function disableExceptionHandling()
{
$this->oldExceptionHandler = $this->app->make(ExceptionHandler::class);
$this->app->instance(ExceptionHandler::class, new class extends Handler {
public function __construct() {}
public function report(\Exception $e) {}
public function render($request, \Exception $e) {
throw $e;
}
});
}
protected function withExceptionHandling()
{
$this->app->instance(ExceptionHandler::class, $this->oldExceptionHandler);
return $this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment