Skip to content

Turn TraitsCachingIssueIntegrationTest into a e2e test #3151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 15, 2024
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
30 changes: 30 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,36 @@ jobs:
- script: |
cd e2e/env-int-key
env 1=1 ../../bin/phpstan analyse test.php
- script: |
cd e2e/trait-caching
../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/
../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/
- script: |
cd e2e/trait-caching
../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/
patch -b data/TraitOne.php < TraitOne.patch
OUTPUT=$(../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/ || true)
echo "$OUTPUT"
[ $(echo "$OUTPUT" | wc -l) -eq 1 ]
grep 'Method TraitsCachingIssue\\TestClassUsingTrait::doBar() should return stdClass but returns Exception.' <<< "$OUTPUT"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This look like a nice opportunity to start using https://bashunit.typeddevs.com/, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure its worth it.

Would the goal be running the tests in a single job?

We would need to start clearing temp folder etc, so it will get more complicated.

Also not sure the assertions would be more readable.

Could you give me a few more directions what you would expect?

Copy link
Contributor Author

@staabm staabm Jun 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will start a new PR to give bashunit a try. this one here should be ready to land.

- script: |
cd e2e/trait-caching
../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/
patch -b data/TraitTwo.php < TraitTwo.patch
OUTPUT=$(../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/ || true)
echo "$OUTPUT"
[ $(echo "$OUTPUT" | wc -l) -eq 1 ]
grep 'Method class@anonymous/TestClassUsingTrait.php:20::doBar() should return stdClass but returns Exception.' <<< "$OUTPUT"
- script: |
cd e2e/trait-caching
../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/
patch -b data/TraitOne.php < TraitOne.patch
patch -b data/TraitTwo.php < TraitTwo.patch
OUTPUT=$(../../bin/phpstan analyze --no-progress --level 8 --error-format raw data/ || true)
echo "$OUTPUT"
[ $(echo "$OUTPUT" | wc -l) -eq 2 ]
grep 'Method TraitsCachingIssue\\TestClassUsingTrait::doBar() should return stdClass but returns Exception.' <<< "$OUTPUT"
grep 'Method class@anonymous/TestClassUsingTrait.php:20::doBar() should return stdClass but returns Exception.' <<< "$OUTPUT"

steps:
- name: "Checkout"
Expand Down
13 changes: 13 additions & 0 deletions e2e/trait-caching/TraitOne.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/e2e/trait-caching/data/TraitOne.php b/e2e/trait-caching/data/TraitOne.php
index 395dc1333a..1641ad6e65 100644
--- a/e2e/trait-caching/data/TraitOne.php
+++ b/e2e/trait-caching/data/TraitOne.php
@@ -2,7 +2,7 @@

namespace TraitsCachingIssue;

-use stdClass as Foo;
+use Exception as Foo;

trait TraitOne
{
13 changes: 13 additions & 0 deletions e2e/trait-caching/TraitTwo.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/e2e/trait-caching/data/TraitTwo.php b/e2e/trait-caching/data/TraitTwo.php
index 1b9827b727..4089407f13 100644
--- a/e2e/trait-caching/data/TraitTwo.php
+++ b/e2e/trait-caching/data/TraitTwo.php
@@ -2,7 +2,7 @@

namespace TraitsCachingIssue;

-use stdClass as Foo;
+use Exception as Foo;

trait TraitTwo
{

This file was deleted.

2 changes: 0 additions & 2 deletions tests/PHPStan/Analyser/traitsCachingIssue/tmp/.gitignore

This file was deleted.