Skip to content

Commit 3018b7c

Browse files
committed
Turn TraitsCachingIssueIntegrationTest into a e2e test
1 parent 047d887 commit 3018b7c

File tree

9 files changed

+56
-186
lines changed

9 files changed

+56
-186
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,36 @@ jobs:
184184
- script: |
185185
cd e2e/env-int-key
186186
env 1=1 ../../bin/phpstan analyse test.php
187+
- script: |
188+
cd e2e/trait-caching
189+
../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/
190+
../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/
191+
- script: |
192+
cd e2e/trait-caching
193+
../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/
194+
patch -b data/TraitOne.php < TraitOne.patch
195+
OUTPUT=$(../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/ || true)
196+
echo "$OUTPUT"
197+
[ $(echo "$OUTPUT" | wc -l) -eq 1 ]
198+
grep 'Method TraitsCachingIssue\\TestClassUsingTrait::doBar() should return stdClass but returns Exception.' <<< "$OUTPUT"
199+
- script: |
200+
cd e2e/trait-caching
201+
../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/
202+
patch -b data/TraitTwo.php < TraitTwo.patch
203+
OUTPUT=$(../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/ || true)
204+
echo "$OUTPUT"
205+
[ $(echo "$OUTPUT" | wc -l) -eq 1 ]
206+
grep 'Method class@anonymous/TestClassUsingTrait.php:20::doBar() should return stdClass but returns Exception.' <<< "$OUTPUT"
207+
- script: |
208+
cd e2e/trait-caching
209+
../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/
210+
patch -b data/TraitOne.php < TraitOne.patch
211+
patch -b data/TraitTwo.php < TraitTwo.patch
212+
OUTPUT=$(../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/ || true)
213+
echo "$OUTPUT"
214+
[ $(echo "$OUTPUT" | wc -l) -eq 2 ]
215+
grep 'Method TraitsCachingIssue\\TestClassUsingTrait::doBar() should return stdClass but returns Exception.' <<< "$OUTPUT"
216+
grep 'Method class@anonymous/TestClassUsingTrait.php:20::doBar() should return stdClass but returns Exception.' <<< "$OUTPUT"
187217
188218
steps:
189219
- name: "Checkout"

e2e/trait-caching/TraitOne.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/e2e/trait-caching/data/TraitOne.php b/e2e/trait-caching/data/TraitOne.php
2+
index 395dc1333a..1641ad6e65 100644
3+
--- a/e2e/trait-caching/data/TraitOne.php
4+
+++ b/e2e/trait-caching/data/TraitOne.php
5+
@@ -2,7 +2,7 @@
6+
7+
namespace TraitsCachingIssue;
8+
9+
-use stdClass as Foo;
10+
+use Exception as Foo;
11+
12+
trait TraitOne
13+
{

e2e/trait-caching/TraitTwo.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/e2e/trait-caching/data/TraitTwo.php b/e2e/trait-caching/data/TraitTwo.php
2+
index 1b9827b727..4089407f13 100644
3+
--- a/e2e/trait-caching/data/TraitTwo.php
4+
+++ b/e2e/trait-caching/data/TraitTwo.php
5+
@@ -2,7 +2,7 @@
6+
7+
namespace TraitsCachingIssue;
8+
9+
-use stdClass as Foo;
10+
+use Exception as Foo;
11+
12+
trait TraitTwo
13+
{

tests/PHPStan/Analyser/traitsCachingIssue/TraitsCachingIssueIntegrationTest.php

Lines changed: 0 additions & 184 deletions
This file was deleted.

tests/PHPStan/Analyser/traitsCachingIssue/tmp/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)