ErrorTest.php 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. class PHPParser_Tests_ErrorTest extends PHPUnit_Framework_TestCase
  3. {
  4. public function testConstruct() {
  5. $error = new PHPParser_Error('Some error', 10);
  6. $this->assertEquals('Some error', $error->getRawMessage());
  7. $this->assertEquals(10, $error->getRawLine());
  8. $this->assertEquals('Some error on line 10', $error->getMessage());
  9. return $error;
  10. }
  11. /**
  12. * @depends testConstruct
  13. */
  14. public function testSetMessageAndLine(PHPParser_Error $error) {
  15. $error->setRawMessage('Some other error');
  16. $error->setRawLine(15);
  17. $this->assertEquals('Some other error', $error->getRawMessage());
  18. $this->assertEquals(15, $error->getRawLine());
  19. $this->assertEquals('Some other error on line 15', $error->getMessage());
  20. }
  21. public function testUnknownLine() {
  22. $error = new PHPParser_Error('Some error');
  23. $this->assertEquals(-1, $error->getRawLine());
  24. $this->assertEquals('Some error on unknown line', $error->getMessage());
  25. }
  26. }