No Description

ParseErrorExceptionTest.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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\ParseErrorException;
  12. class ParseErrorExceptionTest extends \PHPUnit\Framework\TestCase
  13. {
  14. public function testInstance()
  15. {
  16. $e = new ParseErrorException();
  17. $this->assertInstanceOf('Psy\Exception\Exception', $e);
  18. $this->assertInstanceOf('PhpParser\Error', $e);
  19. $this->assertInstanceOf('Psy\Exception\ParseErrorException', $e);
  20. }
  21. public function testMessage()
  22. {
  23. $e = new ParseErrorException('{msg}', 1);
  24. $this->assertContains('{msg}', $e->getMessage());
  25. $this->assertContains('PHP Parse error:', $e->getMessage());
  26. }
  27. public function testConstructFromParseError()
  28. {
  29. $e = ParseErrorException::fromParseError(new \PhpParser\Error('{msg}'));
  30. $this->assertContains('{msg}', $e->getRawMessage());
  31. $this->assertContains('PHP Parse error:', $e->getMessage());
  32. }
  33. }