Skip to content

Commit 4c8f3c6

Browse files
AJenboondrejmirtes
authored andcommitted
Make ResultCacheEndToEndTest pass level 9
1 parent cab49eb commit 4c8f3c6

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

tests/e2e/ResultCacheEndToEndTest.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use PHPStan\File\FileReader;
99
use PHPStan\File\SimpleRelativePathHelper;
1010
use PHPUnit\Framework\TestCase;
11-
use function array_map;
1211
use function chdir;
1312
use function escapeshellarg;
1413
use function exec;
@@ -93,6 +92,7 @@ public function testResultCache(): void
9392
private function runPhpstanWithErrors(): void
9493
{
9594
$result = $this->runPhpstan(1);
95+
$this->assertIsArray($result['totals']);
9696
$this->assertSame(3, $result['totals']['file_errors']);
9797
$this->assertSame(0, $result['totals']['errors']);
9898

@@ -117,6 +117,7 @@ public function testResultCacheDeleteFile(): void
117117
$fileHelper = new FileHelper(__DIR__);
118118

119119
$result = $this->runPhpstan(1);
120+
$this->assertIsArray($result['totals']);
120121
$this->assertSame(1, $result['totals']['file_errors'], Json::encode($result));
121122
$this->assertSame(0, $result['totals']['errors'], Json::encode($result));
122123

@@ -151,6 +152,7 @@ private function runPhpstan(int $expectedExitCode, string $phpstanConfigPath = _
151152

152153
try {
153154
$json = Json::decode($output, Json::FORCE_ARRAY);
155+
$this->assertIsArray($json);
154156
} catch (JsonException $e) {
155157
$this->fail(sprintf('%s: %s', $e->getMessage(), $output));
156158
}
@@ -164,13 +166,22 @@ private function runPhpstan(int $expectedExitCode, string $phpstanConfigPath = _
164166

165167
/**
166168
* @param mixed[] $resultCache
167-
* @return mixed[]
169+
* @return array<string, array<int, string>>
168170
*/
169171
private function transformResultCache(array $resultCache): array
170172
{
171173
$new = [];
174+
$this->assertIsArray($resultCache['dependencies']);
172175
foreach ($resultCache['dependencies'] as $file => $data) {
173-
$files = array_map(fn (string $file): string => $this->relativizePath($file), $data['dependentFiles']);
176+
$this->assertIsString($file);
177+
$this->assertIsArray($data);
178+
$this->assertIsArray($data['dependentFiles']);
179+
180+
$files = [];
181+
foreach ($data['dependentFiles'] as $filePath) {
182+
$this->assertIsString($filePath);
183+
$files[] = $this->relativizePath($filePath);
184+
}
174185
sort($files);
175186
$new[$this->relativizePath($file)] = $files;
176187
}

0 commit comments

Comments
 (0)