|
18 | 18 | use function sort; |
19 | 19 | use function sprintf; |
20 | 20 | use function str_replace; |
| 21 | +use function sys_get_temp_dir; |
21 | 22 | use function unlink; |
22 | 23 | use const DIRECTORY_SEPARATOR; |
23 | 24 | use const FILE_APPEND; |
@@ -127,16 +128,24 @@ public function testResultCacheDeleteFile(): void |
127 | 128 | $this->assertResultCache(__DIR__ . '/resultCache_1.php'); |
128 | 129 | } |
129 | 130 |
|
| 131 | + public function testResultCachePath(): void |
| 132 | + { |
| 133 | + $this->runPhpstan(0, __DIR__ . '/phpstan_resultcachepath.neon'); |
| 134 | + |
| 135 | + $this->assertFileExists(sys_get_temp_dir() . '/phpstan/myResultCacheFile.php'); |
| 136 | + $this->assertResultCache(__DIR__ . '/resultCache_1.php', sys_get_temp_dir() . '/phpstan/myResultCacheFile.php'); |
| 137 | + } |
| 138 | + |
130 | 139 | /** |
131 | 140 | * @return mixed[] |
132 | 141 | */ |
133 | | - private function runPhpstan(int $expectedExitCode): array |
| 142 | + private function runPhpstan(int $expectedExitCode, string $phpstanConfigPath = __DIR__ . '/phpstan.neon'): array |
134 | 143 | { |
135 | 144 | exec(sprintf( |
136 | 145 | '%s %s analyse -c %s -l 5 --no-progress --error-format json lib 2>&1', |
137 | 146 | escapeshellarg(PHP_BINARY), |
138 | 147 | escapeshellarg(__DIR__ . '/../../bin/phpstan'), |
139 | | - escapeshellarg(__DIR__ . '/phpstan.neon'), |
| 148 | + escapeshellarg($phpstanConfigPath), |
140 | 149 | ), $outputLines, $exitCode); |
141 | 150 | $output = implode("\n", $outputLines); |
142 | 151 |
|
@@ -178,10 +187,9 @@ private function relativizePath(string $path): string |
178 | 187 | return $helper->getRelativePath($path); |
179 | 188 | } |
180 | 189 |
|
181 | | - private function assertResultCache(string $expectedCachePath): void |
| 190 | + private function assertResultCache(string $expectedCachePath, string $actualCachePath = __DIR__ . '/tmp/resultCache.php'): void |
182 | 191 | { |
183 | | - $resultCachePath = __DIR__ . '/tmp/resultCache.php'; |
184 | | - $resultCache = $this->transformResultCache(require $resultCachePath); |
| 192 | + $resultCache = $this->transformResultCache(require $actualCachePath); |
185 | 193 | $expectedResultCachePath = require $expectedCachePath; |
186 | 194 | $this->assertSame($expectedResultCachePath, $resultCache); |
187 | 195 | } |
|
0 commit comments