Skip to content

Commit 0419457

Browse files
committed
add testcase for not readable config file
1 parent 7c8e8d3 commit 0419457

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tests/Filesystem/ConfigTest.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace ADR\Filesystem;
44

5+
use org\bovigo\vfs\vfsStream;
56
use RuntimeException;
67
use PHPUnit\Framework\TestCase;
78

@@ -15,11 +16,22 @@ public function testInstanceSuccessfully()
1516
$this->assertEquals('template/skeleton.md', $config->decisionRecordTemplateFile());
1617
}
1718

18-
public function testInstanceFailure()
19+
public function testInstanceNotExistingFailure()
1920
{
2021
$this->expectException(RuntimeException::class);
2122
$this->expectExceptionMessage('The config file does not exist: invalid.yml');
2223

2324
new Config('invalid.yml');
2425
}
26+
27+
public function testInstanceNotReadableFailure()
28+
{
29+
$vfs = vfsStream::setup();
30+
$configFile = vfsStream::newFile('adr.yml')->at($vfs)->chmod(0)->url();
31+
32+
$this->expectException(RuntimeException::class);
33+
$this->expectExceptionMessage("The config file isn't readable: $configFile");
34+
35+
new Config($configFile);
36+
}
2537
}

0 commit comments

Comments
 (0)