FatalErrorExceptionTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /*
  3. * This file is part of Psy Shell.
  4. *
  5. * (c) 2012-2018 Justin Hileman
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Psy\Test\Exception;
  11. use Psy\Exception\FatalErrorException;
  12. class FatalErrorExceptionTest extends \PHPUnit\Framework\TestCase
  13. {
  14. public function testInstance()
  15. {
  16. $e = new FatalErrorException();
  17. $this->assertInstanceOf('Psy\Exception\Exception', $e);
  18. $this->assertInstanceOf('ErrorException', $e);
  19. $this->assertInstanceOf('Psy\Exception\FatalErrorException', $e);
  20. }
  21. public function testMessage()
  22. {
  23. $e = new FatalErrorException('{msg}', 0, 0, '{filename}', 13);
  24. $this->assertSame('{msg}', $e->getRawMessage());
  25. $this->assertContains('{msg}', $e->getMessage());
  26. $this->assertContains('{filename}', $e->getMessage());
  27. $this->assertContains('line 13', $e->getMessage());
  28. }
  29. public function testMessageWithNoFilename()
  30. {
  31. $e = new FatalErrorException('{msg}');
  32. $this->assertSame('{msg}', $e->getRawMessage());
  33. $this->assertContains('{msg}', $e->getMessage());
  34. $this->assertContains('eval()\'d code', $e->getMessage());
  35. }
  36. public function testNegativeOneLineNumberIgnored()
  37. {
  38. $e = new FatalErrorException('{msg}', 0, 1, null, -1);
  39. $this->assertEquals(0, $e->getLine());
  40. }
  41. }