|
6 | 6 | use PHPStan\Testing\PHPStanTestCase; |
7 | 7 | use Symfony\Component\Console\Tester\CommandTester; |
8 | 8 | use Throwable; |
9 | | -use function array_merge; |
10 | 9 | use function chdir; |
11 | 10 | use function getcwd; |
12 | 11 | use function microtime; |
13 | 12 | use function realpath; |
14 | | -use function rename; |
15 | 13 | use function sprintf; |
16 | | -use function unlink; |
17 | 14 | use const DIRECTORY_SEPARATOR; |
18 | 15 | use const PHP_EOL; |
19 | 16 |
|
@@ -74,98 +71,6 @@ public function testValidAutoloadFile(): void |
74 | 71 | } |
75 | 72 | } |
76 | 73 |
|
77 | | - public function testGenerateBaselineIgnoreNewErrorsRemoveFile(): void |
78 | | - { |
79 | | - $baselineFile = __DIR__ . '/data-ignore-new-errors/baseline.neon'; |
80 | | - $this->runCommand(0, [ |
81 | | - 'paths' => [__DIR__ . '/data-ignore-new-errors/A.php', __DIR__ . '/data-ignore-new-errors/B.php'], |
82 | | - '--configuration' => __DIR__ . '/data-ignore-new-errors/empty.neon', |
83 | | - '--level' => '9', |
84 | | - '--generate-baseline' => $baselineFile, |
85 | | - ]); |
86 | | - |
87 | | - $output = $this->runCommand(0, [ |
88 | | - 'paths' => [__DIR__ . '/data-ignore-new-errors/B.php', __DIR__ . '/data-ignore-new-errors/C.php'], |
89 | | - '--configuration' => $baselineFile, |
90 | | - '--level' => '9', |
91 | | - '--generate-baseline' => $baselineFile, |
92 | | - '--only-remove-errors' => true, |
93 | | - ]); |
94 | | - @unlink($baselineFile); |
95 | | - |
96 | | - $this->assertStringContainsString('[OK] Baseline generated with 1 error', $output); |
97 | | - } |
98 | | - |
99 | | - public function testGenerateBaselineIgnoreNewErrorsReducedErrorCount(): void |
100 | | - { |
101 | | - $baselineFile = __DIR__ . '/data-ignore-new-errors-compare/baseline.neon'; |
102 | | - $baselineFileSecondRun = __DIR__ . '/data-ignore-new-errors/baseline.neon'; |
103 | | - $this->runCommand(0, [ |
104 | | - 'paths' => [__DIR__ . '/data-ignore-new-errors-compare/A.php'], |
105 | | - '--configuration' => __DIR__ . '/data-ignore-new-errors-compare/empty.neon', |
106 | | - '--level' => '9', |
107 | | - '--generate-baseline' => $baselineFile, |
108 | | - ]); |
109 | | - |
110 | | - rename($baselineFile, $baselineFileSecondRun); |
111 | | - $output = $this->runCommand(0, [ |
112 | | - 'paths' => [__DIR__ . '/data-ignore-new-errors/A.php'], |
113 | | - '--configuration' => $baselineFileSecondRun, |
114 | | - '--level' => '9', |
115 | | - '--generate-baseline' => $baselineFileSecondRun, |
116 | | - '--only-remove-errors' => true, |
117 | | - ]); |
118 | | - @unlink($baselineFileSecondRun); |
119 | | - |
120 | | - $this->assertStringContainsString('[OK] Baseline generated with 2 errors', $output); |
121 | | - } |
122 | | - |
123 | | - public function testGenerateBaselineIgnoreNewErrorsIncreasedErrorCount(): void |
124 | | - { |
125 | | - $baselineFile = __DIR__ . '/data-ignore-new-errors/baseline.neon'; |
126 | | - $baselineFileSecondRun = __DIR__ . '/data-ignore-new-errors-compare/baseline.neon'; |
127 | | - $this->runCommand(0, [ |
128 | | - 'paths' => [__DIR__ . '/data-ignore-new-errors/A.php'], |
129 | | - '--configuration' => __DIR__ . '/data-ignore-new-errors/empty.neon', |
130 | | - '--level' => '9', |
131 | | - '--generate-baseline' => $baselineFile, |
132 | | - ]); |
133 | | - |
134 | | - rename($baselineFile, $baselineFileSecondRun); |
135 | | - $output = $this->runCommand(0, [ |
136 | | - 'paths' => [__DIR__ . '/data-ignore-new-errors-compare/A.php'], |
137 | | - '--configuration' => $baselineFileSecondRun, |
138 | | - '--level' => '9', |
139 | | - '--generate-baseline' => $baselineFileSecondRun, |
140 | | - '--only-remove-errors' => true, |
141 | | - ]); |
142 | | - @unlink($baselineFileSecondRun); |
143 | | - |
144 | | - $this->assertStringContainsString('[OK] Baseline generated with 2 errors', $output); |
145 | | - } |
146 | | - |
147 | | - public function testGenerateBaselineIgnoreNewErrorsEmptyBaseline(): void |
148 | | - { |
149 | | - $baselineFile = __DIR__ . '/data-ignore-new-errors/baseline.neon'; |
150 | | - $this->runCommand(0, [ |
151 | | - 'paths' => [__DIR__ . '/data-ignore-new-errors/A.php', __DIR__ . '/data-ignore-new-errors/B.php'], |
152 | | - '--configuration' => __DIR__ . '/data-ignore-new-errors/empty.neon', |
153 | | - '--level' => '9', |
154 | | - '--generate-baseline' => $baselineFile, |
155 | | - ]); |
156 | | - |
157 | | - $output = $this->runCommand(1, [ |
158 | | - 'paths' => [__DIR__ . '/data-ignore-new-errors/C.php'], |
159 | | - '--configuration' => $baselineFile, |
160 | | - '--level' => '9', |
161 | | - '--generate-baseline' => $baselineFile, |
162 | | - '--only-remove-errors' => true, |
163 | | - ]); |
164 | | - @unlink($baselineFile); |
165 | | - |
166 | | - $this->assertStringContainsString('[ERROR] No errors were found during the analysis.', $output); |
167 | | - } |
168 | | - |
169 | 74 | /** |
170 | 75 | * @return string[][] |
171 | 76 | */ |
@@ -212,16 +117,16 @@ public static function autoDiscoveryPathsProvider(): array |
212 | 117 | } |
213 | 118 |
|
214 | 119 | /** |
215 | | - * @param array<string, string|string[]|bool> $parameters |
| 120 | + * @param array<string, string> $parameters |
216 | 121 | */ |
217 | 122 | private function runCommand(int $expectedStatusCode, array $parameters = []): string |
218 | 123 | { |
219 | 124 | $commandTester = new CommandTester(new AnalyseCommand([], microtime(true))); |
220 | 125 |
|
221 | | - $commandTester->execute(array_merge([ |
| 126 | + $commandTester->execute([ |
222 | 127 | 'paths' => [__DIR__ . DIRECTORY_SEPARATOR . 'test'], |
223 | 128 | '--debug' => true, |
224 | | - ], $parameters), ['debug' => true]); |
| 129 | + ] + $parameters, ['debug' => true]); |
225 | 130 |
|
226 | 131 | $this->assertSame($expectedStatusCode, $commandTester->getStatusCode(), $commandTester->getDisplay()); |
227 | 132 |
|
|
0 commit comments