Permalink
Browse files

Return empty stack frame context for Unknown files

  • Loading branch information...
victorstanciu committed Nov 15, 2018
1 parent 6372b1b commit bc0501703546a2e62e79d02725dd173c45c49ff5
@@ -17,6 +17,9 @@ class StackFrameContextExtractor
*/
public function getContext($file, $line, $contextLines = 15)
{
if ($file === "Unknown") {
return [];
}
if (!file_exists($file)) {
throw new RuntimeException();
}
@@ -30,6 +30,11 @@ public function testWhenFileDoesNotExist_exceptionIsThrown()
$this->extractor->getContext("/missing/file", 0, 5);
}
public function testWhenFileIsUnknownEmptyArrayIsReturned()
{
$this->assertEquals([], $this->extractor->getContext("Unknown", 0));
}
public function testWhenNegativeLineNumberProvided_exceptionIsThrown()
{
$this->expectException(InvalidArgumentException::class);
@@ -62,7 +67,7 @@ public function testFirstLines()
3 => "Line 3",
4 => "Line 4",
5 => "Line 5",
6 => "Line 6"
6 => "Line 6",
], $this->getContext(1, 5));
}

0 comments on commit bc05017

Please sign in to comment.