ParseErrorExceptionTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /*
  3. * This file is part of Psy Shell.
  4. *
  5. * (c) 2012-2023 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\ParseErrorException;
  13. /**
  14. * @group isolation-fail
  15. */
  16. class ParseErrorExceptionTest extends \Psy\Test\TestCase
  17. {
  18. public function testInstance()
  19. {
  20. $e = new ParseErrorException();
  21. $this->assertInstanceOf(Exception::class, $e);
  22. $this->assertInstanceOf(\PhpParser\Error::class, $e);
  23. $this->assertInstanceOf(ParseErrorException::class, $e);
  24. }
  25. public function testMessage()
  26. {
  27. $e = new ParseErrorException('{msg}', 1);
  28. $this->assertStringContainsString('{msg}', $e->getMessage());
  29. $this->assertStringContainsString('PHP Parse error:', $e->getMessage());
  30. }
  31. public function testConstructFromParseError()
  32. {
  33. $e = ParseErrorException::fromParseError(new \PhpParser\Error('{msg}'));
  34. $this->assertStringContainsString('{msg}', $e->getRawMessage());
  35. $this->assertStringContainsString('PHP Parse error:', $e->getMessage());
  36. }
  37. }