1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace PhelTest\Integration\Run\Command\Ns; |
6
|
|
|
|
7
|
|
|
use Phel\Build\Domain\Extractor\NamespaceInformation; |
|
|
|
|
8
|
|
|
use Phel\Phel; |
9
|
|
|
use Phel\Run\Infrastructure\Command\NsCommand; |
10
|
|
|
use Phel\Run\RunFacadeInterface; |
11
|
|
|
use PhelTest\Integration\Run\Command\AbstractTestCommand; |
12
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
13
|
|
|
|
14
|
|
|
final class NsCommandTest extends AbstractTestCommand |
15
|
|
|
{ |
16
|
|
|
public static function setUpBeforeClass(): void |
17
|
|
|
{ |
18
|
|
|
Phel::bootstrap(__DIR__); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function test_output_loaded_namespaces(): void |
22
|
|
|
{ |
23
|
|
|
$facade = self::createStub(RunFacadeInterface::class); |
24
|
|
|
$facade->method('getLoadedNamespaces') |
25
|
|
|
->willReturn([ |
26
|
|
|
new NamespaceInformation(__FILE__, 'app\\foo', []), |
27
|
|
|
new NamespaceInformation(__FILE__, 'app\\bar', []), |
28
|
|
|
]); |
29
|
|
|
|
30
|
|
|
$command = new class($facade) extends NsCommand { |
31
|
|
|
public function __construct( |
32
|
|
|
private readonly RunFacadeInterface $facade, |
33
|
|
|
) { |
34
|
|
|
parent::__construct(); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
protected function getFacade(): RunFacadeInterface |
38
|
|
|
{ |
39
|
|
|
return $this->facade; |
40
|
|
|
} |
41
|
|
|
}; |
42
|
|
|
|
43
|
|
|
$this->expectOutputRegex('/app\\\\foo/'); |
44
|
|
|
$this->expectOutputRegex('/app\\\\bar/'); |
45
|
|
|
|
46
|
|
|
$command->run( |
47
|
|
|
self::createStub(InputInterface::class), |
48
|
|
|
$this->stubOutput(), |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function test_output_namespace_dependencies(): void |
53
|
|
|
{ |
54
|
|
|
$facade = self::createStub(RunFacadeInterface::class); |
55
|
|
|
$facade->method('getAllPhelDirectories') |
56
|
|
|
->willReturn(['src']); |
57
|
|
|
$facade->method('getDependenciesForNamespace') |
58
|
|
|
->willReturn([ |
59
|
|
|
new NamespaceInformation('foo.phel', 'app\\foo', []), |
60
|
|
|
new NamespaceInformation('bar.phel', 'app\\bar', ['app\\foo']), |
61
|
|
|
]); |
62
|
|
|
|
63
|
|
|
$command = new class($facade) extends NsCommand { |
64
|
|
|
public function __construct(private readonly RunFacadeInterface $facade) |
65
|
|
|
{ |
66
|
|
|
parent::__construct(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
protected function getFacade(): RunFacadeInterface |
70
|
|
|
{ |
71
|
|
|
return $this->facade; |
72
|
|
|
} |
73
|
|
|
}; |
74
|
|
|
|
75
|
|
|
$input = self::createStub(InputInterface::class); |
76
|
|
|
$input->method('getArgument')->willReturn('app\\bar'); |
77
|
|
|
|
78
|
|
|
$this->expectOutputRegex('/Dependencies for namespace: app\\\\bar/'); |
79
|
|
|
$this->expectOutputRegex('/1\) Namespace: app\\\\foo/'); |
80
|
|
|
$this->expectOutputRegex('/Used by: app\\\\bar/'); |
81
|
|
|
$this->expectOutputRegex('/Dependencies: app\\\\foo \(foo\.phel\)/'); |
82
|
|
|
$this->expectOutputRegex('/2\) Namespace: app\\\\bar/'); |
83
|
|
|
$this->expectOutputRegex('/File: bar\.phel/'); |
84
|
|
|
|
85
|
|
|
$command->run( |
86
|
|
|
$input, |
87
|
|
|
$this->stubOutput(), |
88
|
|
|
); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths