Skip to content

Commit

Permalink
Add e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
Wirone committed Jan 7, 2025
1 parent 9fea1e1 commit 2584564
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,15 @@ jobs:
cd e2e/bug-11857
composer install
../../bin/phpstan
- script: |
cd e2e/result-cache-meta-extension
../../bin/phpstan -vvv
../../bin/phpstan -vvv --fail-without-result-cache
echo 'modified-hash' > hash.txt
OUTPUT=$(../bashunit -a exit_code "2" "../../bin/phpstan -vvv --fail-without-result-cache")
echo "$OUTPUT"
../bashunit -a matches "Note: Using configuration file .+phpstan.neon." "$OUTPUT"
../bashunit -a contains 'Result cache not used because the metadata do not match: metaExtensions' "$OUTPUT"
steps:
- name: "Checkout"
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@
"classmap": [
"tests/e2e",
"tests/PHPStan"
],
"files": [
"e2e/result-cache-meta-extension/src/DummyResultCacheMetaExtension.php"
]
},
"repositories": [
Expand Down
1 change: 1 addition & 0 deletions e2e/result-cache-meta-extension/hash.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
initial-hash
10 changes: 10 additions & 0 deletions e2e/result-cache-meta-extension/phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
parameters:
level: 8
paths:
- src

services:
-
class: ResultCacheE2E\MetaExtension\DummyResultCacheMetaExtension
tags:
- phpstan.resultCacheMetaExtension
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace ResultCacheE2E\MetaExtension;

use PHPStan\Analyser\ResultCache\ResultCacheMetaExtension;

final class DummyResultCacheMetaExtension implements ResultCacheMetaExtension
{
public function getKey(): string
{
return 'e2e-self-hashing-result-cache-meta-extension';
}

public function getHash(): string
{
// @phpstan-ignore argument.type (the file is always present so this won't pass `false` as an argument)
return trim(file_get_contents(__DIR__ . '/../hash.txt'));
}
}

0 comments on commit 2584564

Please sign in to comment.