diff --git a/Lib/Config.php b/Lib/Config.php index c35d1f5..a01defb 100644 --- a/Lib/Config.php +++ b/Lib/Config.php @@ -35,9 +35,9 @@ public function __construct(string $composerJsonPath, string $vendorPath, array } $this->composerJsonPath = $composerJsonPath; $this->vendorPath = realpath(rtrim($vendorPath, DIRECTORY_SEPARATOR)) . DIRECTORY_SEPARATOR; - $this->scanDirectories = array_map(static function ($path) { - return realpath(rtrim($path, DIRECTORY_SEPARATOR)) . DIRECTORY_SEPARATOR; - }, $scanDirectories); + $this->scanDirectories = array_filter(array_map(static function ($path) { + return realpath(rtrim($path, DIRECTORY_SEPARATOR). DIRECTORY_SEPARATOR); + }, $scanDirectories)); } public function getComposerJsonPath(): string diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php new file mode 100644 index 0000000..0a7832b --- /dev/null +++ b/tests/ConfigTest.php @@ -0,0 +1,19 @@ +getScanDirectories(); + $this->assertContains(__DIR__.'/stubs/', $dirs); + $this->assertNotContains(__DIR__.'/not_existed/', $dirs); + $this->assertNotContains(__DIR__.'/missing/', $dirs); + } +} \ No newline at end of file diff --git a/tests/scanner_test_config_dev.php b/tests/scanner_test_config_dev.php index 09c6c5a..3dffc42 100644 --- a/tests/scanner_test_config_dev.php +++ b/tests/scanner_test_config_dev.php @@ -3,6 +3,6 @@ return [ 'composerJsonPath' => $projectPath . '/stub_composer.json', 'vendorPath' => $projectPath . '/../vendor/', - 'scanDirectories' => [$projectPath . '/stubs/'], + 'scanDirectories' => [$projectPath . '/stubs/', $projectPath.'/not_existed/', $projectPath.'/missing'], 'requireDev' => true ];