Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions tests/e2e/ResultCacheEndToEndTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use function sort;
use function sprintf;
use function str_replace;
use function sys_get_temp_dir;
use function unlink;
use const DIRECTORY_SEPARATOR;
use const FILE_APPEND;
Expand Down Expand Up @@ -127,16 +128,24 @@ public function testResultCacheDeleteFile(): void
$this->assertResultCache(__DIR__ . '/resultCache_1.php');
}

public function testResultCachePath(): void
{
$this->runPhpstan(0, __DIR__ . '/phpstan_resultcachepath.neon');

$this->assertFileExists(sys_get_temp_dir() . '/phpstan/myResultCacheFile.php');
$this->assertResultCache(__DIR__ . '/resultCache_1.php', sys_get_temp_dir() . '/phpstan/myResultCacheFile.php');
}

/**
* @return mixed[]
*/
private function runPhpstan(int $expectedExitCode): array
private function runPhpstan(int $expectedExitCode, string $phpstanConfigPath = __DIR__ . '/phpstan.neon'): array
{
exec(sprintf(
'%s %s analyse -c %s -l 5 --no-progress --error-format json lib 2>&1',
escapeshellarg(PHP_BINARY),
escapeshellarg(__DIR__ . '/../../bin/phpstan'),
escapeshellarg(__DIR__ . '/phpstan.neon'),
escapeshellarg($phpstanConfigPath),
), $outputLines, $exitCode);
$output = implode("\n", $outputLines);

Expand Down Expand Up @@ -178,10 +187,9 @@ private function relativizePath(string $path): string
return $helper->getRelativePath($path);
}

private function assertResultCache(string $expectedCachePath): void
private function assertResultCache(string $expectedCachePath, string $actualCachePath = __DIR__ . '/tmp/resultCache.php'): void
{
$resultCachePath = __DIR__ . '/tmp/resultCache.php';
$resultCache = $this->transformResultCache(require $resultCachePath);
$resultCache = $this->transformResultCache(require $actualCachePath);
$expectedResultCachePath = require $expectedCachePath;
$this->assertSame($expectedResultCachePath, $resultCache);
}
Expand Down
5 changes: 5 additions & 0 deletions tests/e2e/phpstan_resultcachepath.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
includes:
- baseline.neon

parameters:
resultCachePath: %tmpDir%/myResultCacheFile.php