Throwing an exception when loading a directory

This commit is contained in:
Sanpi 2017-04-07 18:56:33 +02:00
parent 49ae724e9c
commit 8b83b58aa5
2 changed files with 10 additions and 1 deletions

View File

@ -48,7 +48,7 @@ final class Dotenv
{
// func_get_args() to be replaced by a variadic argument for Symfony 4.0
foreach (func_get_args() as $path) {
if (!is_readable($path)) {
if (!is_readable($path) || is_dir($path)) {
throw new PathException($path);
}

View File

@ -145,4 +145,13 @@ class DotenvTest extends TestCase
return $tests;
}
/**
* @expectedException \Symfony\Component\Dotenv\Exception\PathException
*/
public function testLoadDirectory()
{
$dotenv = new Dotenv();
$dotenv->load(__DIR__);
}
}