[TestFramework] Stopped marking transaction in integration tests as inactive although they're still active #39429
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description (*)
Before an integration test is started the testing framework begins a new database transaction so that all changes to the database can be reverted after the test is completed.
The testing framework also offers a way to easily load data fixtures during this transaction with the help of the
Magento\TestFramework\Fixture\DataFixture
attribute. But in case of faulty fixtures an exception or error can occur. Currently this will prevent theendTest
event from rolling back the transaction and so the tests fail with the error message:instead of showing the real reason of the error.
The reason why the transaction is not rolled back correctly is that the catch block in the Transaction event marks the transaction as 'inactive' (see here) so that it won't be rolled back at the end of the test (see here), although the transaction is still open.
This PR fixes this behaviour so that the transaction is rolled back after the test execution and the correct error messages is shown in the console output.
Manual testing scenarios (*)
Add an integration test to your own test suite that uses a data fixture with an invalid config. For example:
Now, run the test and you should get this output:
After applying this PR the output of phpunit shows the following:
This helps the developer to find the real issue. The previous message 'Some transactions have not been committed or rolled back' does not help.
Contribution checklist (*)
Resolved issues: