Skip to content

Commit 6106e3d

Browse files
clxmstaabstaabm
authored andcommitted
e2e test resultCachePath
1 parent 4bfe421 commit 6106e3d

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

tests/e2e/ResultCacheEndToEndTest.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use function sort;
1919
use function sprintf;
2020
use function str_replace;
21+
use function sys_get_temp_dir;
2122
use function unlink;
2223
use const DIRECTORY_SEPARATOR;
2324
use const FILE_APPEND;
@@ -127,16 +128,24 @@ public function testResultCacheDeleteFile(): void
127128
$this->assertResultCache(__DIR__ . '/resultCache_1.php');
128129
}
129130

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+
130139
/**
131140
* @return mixed[]
132141
*/
133-
private function runPhpstan(int $expectedExitCode): array
142+
private function runPhpstan(int $expectedExitCode, string $phpstanConfigPath = __DIR__ . '/phpstan.neon'): array
134143
{
135144
exec(sprintf(
136145
'%s %s analyse -c %s -l 5 --no-progress --error-format json lib 2>&1',
137146
escapeshellarg(PHP_BINARY),
138147
escapeshellarg(__DIR__ . '/../../bin/phpstan'),
139-
escapeshellarg(__DIR__ . '/phpstan.neon'),
148+
escapeshellarg($phpstanConfigPath),
140149
), $outputLines, $exitCode);
141150
$output = implode("\n", $outputLines);
142151

@@ -178,10 +187,9 @@ private function relativizePath(string $path): string
178187
return $helper->getRelativePath($path);
179188
}
180189

181-
private function assertResultCache(string $expectedCachePath): void
190+
private function assertResultCache(string $expectedCachePath, string $actualCachePath = __DIR__ . '/tmp/resultCache.php'): void
182191
{
183-
$resultCachePath = __DIR__ . '/tmp/resultCache.php';
184-
$resultCache = $this->transformResultCache(require $resultCachePath);
192+
$resultCache = $this->transformResultCache(require $actualCachePath);
185193
$expectedResultCachePath = require $expectedCachePath;
186194
$this->assertSame($expectedResultCachePath, $resultCache);
187195
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
includes:
2+
- baseline.neon
3+
4+
parameters:
5+
resultCachePath: %tmpDir%/myResultCacheFile.php

0 commit comments

Comments
 (0)