Skip to content

Relate deprecations from DataProvider with corresponding tests #6293

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

Closed
wants to merge 4 commits into from

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Aug 6, 2025

fixes #6279

idea is, that we relate deprecations when triggered while building a dataprovider to the corresponding test


we cannot use $test = Event\Code\TestMethodBuilder::fromCallStack(); to infer the test-contex, as the dataprovider is built before we enter the actual test

use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

class TriggersDeprecationInDataProviderTest extends TestCase
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we can add a case where two tests relate to the same data provider?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added more tests

@nikophil
Copy link
Contributor

nikophil commented Aug 7, 2025

@staabm shouldn't this PR target v12 ?

in my understanding it fixes a problem introduced by #6165 in 12.2

@staabm
Copy link
Contributor Author

staabm commented Aug 7, 2025

You might be right. I will let this decision to Sebastian

@xabbuh
Copy link
Contributor

xabbuh commented Aug 11, 2025

As commented in #6279 (comment) this change would unblock Symfony to use PHPUnit > 12.1.

I think it could be worse to expand the tests with a test that uses the #[IgnoreDeprecations] attribute to prove that this is sufficient to silence deprecations.

I was also wondering how PHPUnit behaves if you use the same data provider with both tests ignoring deprecations as well as not ignoring them. The result looks expected to me but it may also be worth adding a test for that (maybe also doing two distinct cases to prove that the order doesn't matter, i.e. the behaviour is the same no matter if the ignoring deprecations test comes before or after the not ignoring test inside the test class).

@staabm
Copy link
Contributor Author

staabm commented Aug 11, 2025

@xabbuh please suggest/PR concrete test examples you have in mind

@sebastianbergmann
Copy link
Owner

Cherry-picked into 12.3 and merged to main from there.

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.

Deprecation triggered in data provider method affects all test methods using that data provider method
4 participants