FatalErrorExceptionTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /*
  3. * This file is part of Psy Shell.
  4. *
  5. * (c) 2012-2017 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\Exception;
  12. use Psy\Exception\FatalErrorException;
  13. class FatalErrorExceptionTest extends \PHPUnit_Framework_TestCase
  14. {
  15. public function testInstance()
  16. {
  17. $e = new FatalErrorException();
  18. $this->assertTrue($e instanceof Exception);
  19. $this->assertTrue($e instanceof \ErrorException);
  20. $this->assertTrue($e instanceof FatalErrorException);
  21. }
  22. public function testMessage()
  23. {
  24. $e = new FatalErrorException('{msg}', 0, 0, '{filename}', 13);
  25. $this->assertEquals('{msg}', $e->getRawMessage());
  26. $this->assertContains('{msg}', $e->getMessage());
  27. $this->assertContains('{filename}', $e->getMessage());
  28. $this->assertContains('line 13', $e->getMessage());
  29. }
  30. public function testMessageWithNoFilename()
  31. {
  32. $e = new FatalErrorException('{msg}');
  33. $this->assertEquals('{msg}', $e->getRawMessage());
  34. $this->assertContains('{msg}', $e->getMessage());
  35. $this->assertContains('eval()\'d code', $e->getMessage());
  36. }
  37. }