Skip to content
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

fix: Ensure the database is not populated several times in PHP 8.2 #43

Merged
merged 2 commits into from
Sep 19, 2023

Conversation

theofidry
Copy link
Owner

@theofidry theofidry commented Sep 19, 2023

In PHP 8.2 static properties declared in traits behaves as if they were declared in the class using the trait, hence it will no longer be shared between classes using this trait.

Closes #42.

This PR is another take of #42 where the state is kept within an internal constant instead as a constant would mean introducing global state that cannot be mutated which I am not too found of.

TravisMarkvh and others added 2 commits September 10, 2023 09:02
In PHP 8.2 static properties in traits were no longer supported.
Due to this issue the database was populated every time at the beginning of a new test class in the refresh trait.

Now we are using a defined var to store if the db is already populated.
@theofidry theofidry merged commit 841ac01 into master Sep 19, 2023
@theofidry theofidry deleted the TravisMarkvh/master branch September 19, 2023 19:48
@theofidry
Copy link
Owner Author

Thank you @TravisMarkvh! Sorry for the delay.

wuchen90 added a commit to wuchen90/AliceBundle that referenced this pull request Sep 21, 2023
After this PR theofidry#43, the `self::$fixtures` isn't populated anymore for the tests that are located in other classes.
Since the population code is executed only once and stores the fixtures into the first test class static `$fixtures` variable, the other class will get `self::$fixtures === null`.
wuchen90 added a commit to wuchen90/AliceBundle that referenced this pull request Sep 21, 2023
After this PR theofidry#43, the `self::$fixtures` isn't populated anymore for the tests that are located in other classes.
Since the population code is executed only once and stores the fixtures into the first test class static `$fixtures` variable, the other class will get `self::$fixtures === null`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants