SyntaxErrorExceptionTest.php 987 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace JmesPath\Tests;
  3. use JmesPath\SyntaxErrorException;
  4. use PHPUnit\Framework\TestCase;
  5. /**
  6. * @covers JmesPath\SyntaxErrorException
  7. */
  8. class SyntaxErrorExceptionTest extends TestCase
  9. {
  10. public function testCreatesWithNoArray()
  11. {
  12. $e = new SyntaxErrorException(
  13. 'Found comma',
  14. ['type' => 'comma', 'pos' => 3, 'value' => ','],
  15. 'abc,def'
  16. );
  17. $expected = <<<EOT
  18. Syntax error at character 3
  19. abc,def
  20. ^
  21. Found comma
  22. EOT;
  23. $this->assertContains($expected, $e->getMessage());
  24. }
  25. public function testCreatesWithArray()
  26. {
  27. $e = new SyntaxErrorException(
  28. ['dot' => true, 'eof' => true],
  29. ['type' => 'comma', 'pos' => 3, 'value' => ','],
  30. 'abc,def'
  31. );
  32. $expected = <<<EOT
  33. Syntax error at character 3
  34. abc,def
  35. ^
  36. Expected one of the following: dot, eof; found comma ","
  37. EOT;
  38. $this->assertContains($expected, $e->getMessage());
  39. }
  40. }