Skip to content

Commit 2584564

Browse files
committed
Add e2e test
1 parent 9fea1e1 commit 2584564

File tree

5 files changed

+44
-0
lines changed

5 files changed

+44
-0
lines changed

.github/workflows/e2e-tests.yml

+9
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,15 @@ jobs:
233233
cd e2e/bug-11857
234234
composer install
235235
../../bin/phpstan
236+
- script: |
237+
cd e2e/result-cache-meta-extension
238+
../../bin/phpstan -vvv
239+
../../bin/phpstan -vvv --fail-without-result-cache
240+
echo 'modified-hash' > hash.txt
241+
OUTPUT=$(../bashunit -a exit_code "2" "../../bin/phpstan -vvv --fail-without-result-cache")
242+
echo "$OUTPUT"
243+
../bashunit -a matches "Note: Using configuration file .+phpstan.neon." "$OUTPUT"
244+
../bashunit -a contains 'Result cache not used because the metadata do not match: metaExtensions' "$OUTPUT"
236245
237246
steps:
238247
- name: "Checkout"

composer.json

+3
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@
140140
"classmap": [
141141
"tests/e2e",
142142
"tests/PHPStan"
143+
],
144+
"files": [
145+
"e2e/result-cache-meta-extension/src/DummyResultCacheMetaExtension.php"
143146
]
144147
},
145148
"repositories": [
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
initial-hash
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
parameters:
2+
level: 8
3+
paths:
4+
- src
5+
6+
services:
7+
-
8+
class: ResultCacheE2E\MetaExtension\DummyResultCacheMetaExtension
9+
tags:
10+
- phpstan.resultCacheMetaExtension
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ResultCacheE2E\MetaExtension;
6+
7+
use PHPStan\Analyser\ResultCache\ResultCacheMetaExtension;
8+
9+
final class DummyResultCacheMetaExtension implements ResultCacheMetaExtension
10+
{
11+
public function getKey(): string
12+
{
13+
return 'e2e-self-hashing-result-cache-meta-extension';
14+
}
15+
16+
public function getHash(): string
17+
{
18+
// @phpstan-ignore argument.type (the file is always present so this won't pass `false` as an argument)
19+
return trim(file_get_contents(__DIR__ . '/../hash.txt'));
20+
}
21+
}

0 commit comments

Comments
 (0)