10, 'endLine' => 11, )); $this->assertSame('Some error', $error->getRawMessage()); $this->assertSame(10, $error->getStartLine()); $this->assertSame(11, $error->getEndLine()); $this->assertSame(10, $error->getRawLine()); $this->assertSame('Some error on line 10', $error->getMessage()); return $error; } /** * @depends testConstruct */ public function testSetMessageAndLine(Error $error) { $error->setRawMessage('Some other error'); $this->assertSame('Some other error', $error->getRawMessage()); $error->setStartLine(15); $this->assertSame(15, $error->getStartLine()); $this->assertSame('Some other error on line 15', $error->getMessage()); $error->setStartLine(17); $this->assertSame(17, $error->getRawLine()); $this->assertSame('Some other error on line 17', $error->getMessage()); } public function testUnknownLine() { $error = new Error('Some error'); $this->assertSame(-1, $error->getStartLine()); $this->assertSame(-1, $error->getEndLine()); $this->assertSame(-1, $error->getRawLine()); $this->assertSame('Some error on unknown line', $error->getMessage()); } /** @dataProvider provideTestColumnInfo */ public function testColumnInfo($code, $startPos, $endPos, $startColumn, $endColumn) { $error = new Error('Some error', array( 'startFilePos' => $startPos, 'endFilePos' => $endPos, )); $this->assertSame(true, $error->hasColumnInfo()); $this->assertSame($startColumn, $error->getStartColumn($code)); $this->assertSame($endColumn, $error->getEndColumn($code)); } public function provideTestColumnInfo() { return array( // Error at "bar" array("assertSame(false, $error->hasColumnInfo()); try { $error->getStartColumn(''); $this->fail('Expected RuntimeException'); } catch (\RuntimeException $e) { $this->assertEquals('Error does not have column information', $e->getMessage()); } try { $error->getEndColumn(''); $this->fail('Expected RuntimeException'); } catch (\RuntimeException $e) { $this->assertEquals('Error does not have column information', $e->getMessage()); } } }