2011-11-27 21:43:27 +01:00
|
|
|
<?php
|
|
|
|
|
2014-02-06 14:44:16 +01:00
|
|
|
namespace PhpParser;
|
|
|
|
|
|
|
|
class ErrorTest extends \PHPUnit_Framework_TestCase
|
2011-11-27 21:43:27 +01:00
|
|
|
{
|
|
|
|
public function testConstruct() {
|
2014-02-06 14:44:16 +01:00
|
|
|
$error = new Error('Some error', 10);
|
2011-11-27 21:43:27 +01:00
|
|
|
|
|
|
|
$this->assertEquals('Some error', $error->getRawMessage());
|
|
|
|
$this->assertEquals(10, $error->getRawLine());
|
|
|
|
$this->assertEquals('Some error on line 10', $error->getMessage());
|
|
|
|
|
|
|
|
return $error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @depends testConstruct
|
|
|
|
*/
|
2014-02-06 14:44:16 +01:00
|
|
|
public function testSetMessageAndLine(Error $error) {
|
2011-11-27 21:43:27 +01:00
|
|
|
$error->setRawMessage('Some other error');
|
|
|
|
$error->setRawLine(15);
|
|
|
|
|
|
|
|
$this->assertEquals('Some other error', $error->getRawMessage());
|
|
|
|
$this->assertEquals(15, $error->getRawLine());
|
|
|
|
$this->assertEquals('Some other error on line 15', $error->getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testUnknownLine() {
|
2014-02-06 14:44:16 +01:00
|
|
|
$error = new Error('Some error');
|
2011-11-27 21:43:27 +01:00
|
|
|
|
|
|
|
$this->assertEquals(-1, $error->getRawLine());
|
|
|
|
$this->assertEquals('Some error on unknown line', $error->getMessage());
|
|
|
|
}
|
|
|
|
}
|