-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Validator] Unit Tests #13898
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
[Validator] Unit Tests #13898
Conversation
|
||
protected function createValidator() | ||
{ | ||
return new ContainsAlphanumericValidator(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about using the ProtocolClassValidator
here that we implemented above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I see, the ProtocolClassValidator
is more like 'sketchy' snippet, no real logic in there. Ergo I am not sure that we can produce some significant unit test example for it. Maybe we should improve the ProtocolClassValidator
snippet? @xabbuh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would work for me too. As long as we use a consistent example throughout this document the experience when reading the article will be better IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@henry2778 it would be very great if you could use (and enhance) the ProtocolClassValidator
to stay consistent across the document. Thanks
@OskarStark @xabbuh please have a look. I decided to add some small snippet with simple logic instead of foobar-s. Thanks! :) |
Hi @henry2778! This PR must have slipped of our radar, and we merged another PR that documented unit testing custom constraints a couple months ago (#17124). However, I really like the work you did on this PR by creating real examples and using it consistently across the article. I've taken your commit and combined it with the recent changes to the article in #17335 . Thanks a lot for your work here! |
#13898) (henry2778, wouterj) This PR was merged into the 4.4 branch. Discussion ---------- [Validator] Modernize Custom constraints article (finishes #13898) Replaces #13898 While the main addition of that PR was unit tests (which we merged from a concurrent PR), it also brought some great other things: Real & consistent examples. Let's get them in the docs :) Also, I've added the type declarations to this article (like we are doing in most examples at the moment). Commits ------- 7bd5193 [Validator] Combine #13898 with recent changes 9cbca1a [Validator] Unit Tests
* 4.4: Change secure.php.net link to php.net [Validator] Combine symfony#13898 with recent changes [Serializer] Remove note about installing the FrameworkExtraBundle for using annotations [Validator] Unit Tests
* 5.4: Change secure.php.net link to php.net [Validator] Combine symfony#13898 with recent changes [Serializer] Remove note about installing the FrameworkExtraBundle for using annotations [Validator] Unit Tests
* 6.0: Change secure.php.net link to php.net [Validator] Combine symfony#13898 with recent changes [Serializer] Remove note about installing the FrameworkExtraBundle for using annotations [Validator] Unit Tests
* 6.1: Change secure.php.net link to php.net [Validator] Combine symfony#13898 with recent changes [Serializer] Remove note about installing the FrameworkExtraBundle for using annotations [Validator] Unit Tests
Hi guys! This PR adds some theory about creating unit tests for custom constraint validator. I am aware that there is a PR for that already (#12676). However, I suggest this PR as shorter one and more consistent with the rest of the article itself. Thanks! :)