SyntaxErrorExceptionTest.php 974 B

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