Skip to content

Commit 3945ecb

Browse files
committed
Add tests for new exceptions in parseFromFile
1 parent c4bfe12 commit 3945ecb

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/CommentTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,23 @@ public function testParseFromFile()
6868
$this->assertSame('adhocore/json-comment', $parsed['name']);
6969
}
7070

71+
public function testParseFromFileThrowsNotExists()
72+
{
73+
$this->expectException(\RuntimeException::class);
74+
$this->expectExceptionMessage('File does-not-exist.json does not exist');
75+
76+
Comment::parseFromFile('does-not-exist.json', true);
77+
}
78+
79+
public function testParseFromFileThrowsNotFile()
80+
{
81+
$this->expectException(\RuntimeException::class);
82+
$this->expectExceptionMessage(__DIR__ . ' is not a file');
83+
84+
Comment::parseFromFile(__DIR__, true);
85+
}
86+
87+
7188
public function testSubJson()
7289
{
7390
// https://github.com/adhocore/php-json-comment/issues/15

0 commit comments

Comments
 (0)