Skip to content

[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

Closed
wants to merge 6 commits into from

Conversation

henry2778
Copy link
Contributor

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! :)

@xabbuh xabbuh added this to the 3.4 milestone Aug 3, 2020

protected function createValidator()
{
return new ContainsAlphanumericValidator();
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor

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

@henry2778
Copy link
Contributor Author

@OskarStark @xabbuh please have a look. I decided to add some small snippet with simple logic instead of foobar-s. Thanks! :)

@henry2778 henry2778 requested review from OskarStark and removed request for HeahDude April 3, 2021 08:00
wouterj added a commit to wouterj/symfony-docs that referenced this pull request Oct 9, 2022
wouterj added a commit to wouterj/symfony-docs that referenced this pull request Oct 9, 2022
@wouterj
Copy link
Member

wouterj commented Oct 9, 2022

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!

@wouterj wouterj closed this Oct 9, 2022
wouterj added a commit to wouterj/symfony-docs that referenced this pull request Oct 9, 2022
wouterj added a commit to wouterj/symfony-docs that referenced this pull request Oct 16, 2022
javiereguiluz added a commit that referenced this pull request Oct 18, 2022
#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
javiereguiluz added a commit to javiereguiluz/symfony-docs that referenced this pull request Oct 18, 2022
* 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
javiereguiluz added a commit to javiereguiluz/symfony-docs that referenced this pull request Oct 18, 2022
* 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
javiereguiluz added a commit to javiereguiluz/symfony-docs that referenced this pull request Oct 18, 2022
* 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
javiereguiluz added a commit to javiereguiluz/symfony-docs that referenced this pull request Oct 18, 2022
* 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
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.

6 participants