RenderIgnitionPageTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace Facade\Ignition\Tests;
  3. use Exception;
  4. use Illuminate\Support\Facades\Route;
  5. use Illuminate\Support\Str;
  6. class RenderIgnitionPageTest extends TestCase
  7. {
  8. public function setUp(): void
  9. {
  10. parent::setUp();
  11. config()->set('app.debug', true);
  12. Route::get('will-fail', function () {
  13. throw new Exception('My exception');
  14. });
  15. }
  16. /** @test */
  17. public function when_requesting_html_it_will_respond_with_html()
  18. {
  19. /** @var \Illuminate\Http\Response $response */
  20. $response = $this
  21. ->get('will-fail')
  22. ->baseResponse;
  23. $this->assertStringStartsWith('text/html', $response->headers->get('Content-Type'));
  24. $this->assertTrue(Str::contains($response->getContent(), 'html'));
  25. }
  26. /** @test */
  27. public function when_requesting_json_it_will_respond_with_json()
  28. {
  29. /** @var \Illuminate\Http\Response $response */
  30. $response = $this
  31. ->getJson('will-fail');
  32. $this->assertStringStartsWith('application/json', $response->headers->get('Content-Type'));
  33. $this->assertEquals('My exception', json_decode($response->getContent(), true)['message']);
  34. }
  35. }