InspectorTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * Whoops - php errors for cool kids
  4. * @author Filipe Dobreira <http://github.com/filp>
  5. */
  6. namespace Whoops\Exception;
  7. use Whoops\Exception\Inspector;
  8. use Whoops\TestCase;
  9. use RuntimeException;
  10. use Exception;
  11. use Mockery as m;
  12. class InspectorTest extends TestCase
  13. {
  14. /**
  15. * @param string $message
  16. * @return Exception
  17. */
  18. protected function getException($message = null)
  19. {
  20. return m::mock('Exception', array($message));
  21. }
  22. /**
  23. * @param Exception $exception|null
  24. * @return Whoops\Exception\Inspector
  25. */
  26. protected function getInspectorInstance(Exception $exception = null)
  27. {
  28. return new Inspector($exception);
  29. }
  30. /**
  31. * @covers Whoops\Exception\Inspector::getExceptionName
  32. */
  33. public function testReturnsCorrectExceptionName()
  34. {
  35. $exception = $this->getException();
  36. $inspector = $this->getInspectorInstance($exception);
  37. $this->assertEquals(get_class($exception), $inspector->getExceptionName());
  38. }
  39. /**
  40. * @covers Whoops\Exception\Inspector::__construct
  41. * @covers Whoops\Exception\Inspector::getException
  42. */
  43. public function testExceptionIsStoredAndReturned()
  44. {
  45. $exception = $this->getException();
  46. $inspector = $this->getInspectorInstance($exception);
  47. $this->assertSame($exception, $inspector->getException());
  48. }
  49. /**
  50. * @covers Whoops\Exception\Inspector::getFrames
  51. */
  52. public function testGetFramesReturnsCollection()
  53. {
  54. $exception = $this->getException();
  55. $inspector = $this->getInspectorInstance($exception);
  56. $this->assertInstanceOf('Whoops\\Exception\\FrameCollection', $inspector->getFrames());
  57. }
  58. }