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

ConstraintValidatorTestCase and PHPUnit 10 #49218

Closed
gjuric opened this issue Feb 3, 2023 · 1 comment
Closed

ConstraintValidatorTestCase and PHPUnit 10 #49218

gjuric opened this issue Feb 3, 2023 · 1 comment
Labels
Bug Help wanted Issues and PRs which are looking for volunteers to complete them. Status: Reviewed Validator

Comments

@gjuric
Copy link
Contributor

gjuric commented Feb 3, 2023

Symfony version(s) affected

all

Description

When validating custom Constraints Symfony\Component\Validator\Test\ConstraintValidatorTestCase is used.

During setup ConstraintValidatorTestCase is setting context by calling MockBuilder::setMethods() that was removed in PHPUnit 10 (see sebastianbergmann/phpunit#3769 ).

How to reproduce

Install PHPUnit 10 and write a custom validator test as explained in the documentation.

Possible Solution

Check version of PHPUnit being used and replace a call to MockBuilder::setMethods() with MockBuilder::onlyMethods() if PHPUnit >= 10.0 is detected.

Additional Context

No response

@derrabus
Copy link
Member

derrabus commented Feb 3, 2023

PR welcome to fix that on the 5.4 branch. We cannot use PHPUnit 10 in our CI just yet, but all the methods you need should exist on PHPUnit 9.6 already.

@derrabus derrabus added Status: Reviewed Help wanted Issues and PRs which are looking for volunteers to complete them. and removed Status: Needs Review labels Feb 3, 2023
gjuric added a commit to gjuric/symfony that referenced this issue Feb 3, 2023
As explained in symfony#49218 `MockBuilder::setMethods()` has been removed from PHPUnit 10
and replaced with `MockBuilder::onlyMethods()`. This change checks if `onlyMethods()`
is defined and if not falls back to old version that uses `setMethods()`.
@fabpot fabpot closed this as completed Feb 4, 2023
fabpot added a commit that referenced this issue Feb 4, 2023
…th PHPUnit 10 (gjuric)

This PR was squashed before being merged into the 5.4 branch.

Discussion
----------

[Validator] Make ConstraintValidatorTestCase compatible with PHPUnit 10

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #49218
| License       | MIT

As explained in #49218 `MockBuilder::setMethods()` has been removed from PHPUnit 10 and replaced with `MockBuilder::onlyMethods()`. This change checks if `onlyMethods()` is defined and if not falls back to old version that uses `setMethods()`.

Commits
-------

7aa4fee [Validator] Make ConstraintValidatorTestCase compatible with PHPUnit 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Help wanted Issues and PRs which are looking for volunteers to complete them. Status: Reviewed Validator
Projects
None yet
Development

No branches or pull requests

5 participants