Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Validator][Tests] Fix AssertingContextualValidator not throwing on remaining expectations #42458

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

Conversation

fancyweb
Copy link
Contributor

@fancyweb fancyweb commented Aug 9, 2021

Q A
Branch? 4.4
Bug fix? no
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

While working on something I noticed two missing things in the AssertingContextualValidator.

  1. We don't check if there are remaining expected calls when the AssertingContextualValidator is destroyed. Therefore the tests using it always pass, whether the validator actually calls validate or not. (for example: comment the ->validate() line in AllValidator and tests still pass)
    2. When the expected value / value is an object, we should use assertEquals because it cannot logically be the same instance.

Ping @xabbuh

@carsonbot carsonbot added this to the 4.4 milestone Aug 9, 2021
@carsonbot carsonbot changed the title [Validator][Tests] Improve AssertingContextualValidator checks [Validator] [Tests] Improve AssertingContextualValidator checks Aug 9, 2021
@carsonbot
Copy link

Hey!

I think @przemyslaw-bogusz has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

Copy link
Member

@fabpot fabpot left a comment

Choose a reason for hiding this comment

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

LGTM but I'm not sure about the AssertEquals() part for objects. /cc @xabbuh

@fancyweb fancyweb force-pushed the validator/test-assert-contextual branch from 9b458d2 to 27d0fda Compare November 25, 2021 13:43
@nicolas-grekas
Copy link
Member

nicolas-grekas commented Nov 28, 2021

Shouldn't this be covered by some tests?
/cc @xabbuh available for a review please? 🙏

@fancyweb fancyweb force-pushed the validator/test-assert-contextual branch from 27d0fda to b409cb2 Compare December 31, 2021 10:31
@fancyweb fancyweb force-pushed the validator/test-assert-contextual branch from b409cb2 to aac1013 Compare December 31, 2021 10:32
@fancyweb fancyweb changed the title [Validator] [Tests] Improve AssertingContextualValidator checks [Validator][Tests] Fix AssertingContextualValidator not throwing on remaining expectations Dec 31, 2021
@fancyweb
Copy link
Contributor Author

I added a test. I reverted the assertEquals() for objects because it's in the case where you mutate the validated value in the validator (for example, the value in the validator is a string, you construct a \DateTime from it and you validate the \DateTime instance). I guess that could be considered as a bad practice so I decided I don't care for now.

@fancyweb
Copy link
Contributor Author

@fabpot @xabbuh @nicolas-grekas I'm attempting another ping on this one because it's a real bug and I would like it to be fixed 😅

@nicolas-grekas
Copy link
Member

Thank you @fancyweb.

@nicolas-grekas nicolas-grekas merged commit 75bf7fa into symfony:4.4 Feb 23, 2022
@fancyweb fancyweb deleted the validator/test-assert-contextual branch February 23, 2022 13:25
This was referenced Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.