AddExceptionInformationTest.php 1002 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace Facade\Ignition\Tests\Middleware;
  3. use Exception;
  4. use Facade\Ignition\Facades\Flare;
  5. use Facade\Ignition\Tests\TestCase;
  6. use Illuminate\Database\QueryException;
  7. class AddExceptionInformationTest extends TestCase
  8. {
  9. /** @test */
  10. public function it_will_add_query_information_with_a_query_exception()
  11. {
  12. $sql = 'select * from users where emai = "ruben@spatie.be"';
  13. $report = Flare::createReport(new QueryException(
  14. '' . $sql . '',
  15. [],
  16. new Exception()
  17. ));
  18. $context = $report->toArray()['context'];
  19. $this->assertArrayHasKey('exception', $context);
  20. $this->assertSame($sql, $context['exception']['raw_sql']);
  21. }
  22. /** @test */
  23. public function it_wont_add_query_information_without_a_query_exception()
  24. {
  25. $report = Flare::createReport(new Exception());
  26. $context = $report->toArray()['context'];
  27. $this->assertArrayNotHasKey('exception', $context);
  28. }
  29. }