RenderableViewExceptionTest.php 848 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace Illuminate\Tests\Integration\View;
  3. use Exception;
  4. use Illuminate\Http\Response;
  5. use Illuminate\Support\Facades\Route;
  6. use Illuminate\Support\Facades\View;
  7. use Orchestra\Testbench\TestCase;
  8. class RenderableViewExceptionTest extends TestCase
  9. {
  10. public function testRenderMethodOfExceptionThrownInViewGetsHandled()
  11. {
  12. Route::get('/', function () {
  13. return View::make('renderable-exception');
  14. });
  15. $response = $this->get('/');
  16. $response->assertSee('This is a renderable exception.');
  17. }
  18. protected function getEnvironmentSetUp($app)
  19. {
  20. $app['config']->set('view.paths', [__DIR__.'/templates']);
  21. }
  22. }
  23. class RenderableException extends Exception
  24. {
  25. public function render($request)
  26. {
  27. return new Response('This is a renderable exception.');
  28. }
  29. }