Skip to content

Commit

Permalink
fix #34
Browse files Browse the repository at this point in the history
  • Loading branch information
Insolita committed Apr 14, 2021
1 parent 21e66e9 commit 88f3111
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Lib/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions tests/ConfigTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace tests;

use insolita\Scanner\Lib\Config;
use PHPUnit\Framework\TestCase;

class ConfigTest extends TestCase
{
public function testConfigShouldSkipUnexistedDirs()
{
$params = require __DIR__ . '/scanner_test_config_dev.php';
$config = Config::create($params);
$dirs = $config->getScanDirectories();
$this->assertContains(__DIR__.'/stubs/', $dirs);
$this->assertNotContains(__DIR__.'/not_existed/', $dirs);
$this->assertNotContains(__DIR__.'/missing/', $dirs);
}
}
2 changes: 1 addition & 1 deletion tests/scanner_test_config_dev.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
];

0 comments on commit 88f3111

Please sign in to comment.