-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add docs to register custom form extensions and types for unit testing #7578
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
Conversation
form/unit_testing.rst
Outdated
If your forms uses the ``invalid_message`` or ``constraints`` option for validation, you need to | ||
register the validation extension which provides this options. | ||
Luckily Symfony provides a custom test class which does this for you. | ||
In order to have this option registered, your test needs to extend from the |
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.
to extend the .. class would be better, no ? (Without from)
form/unit_testing.rst
Outdated
@@ -156,12 +156,31 @@ make sure the ``FormRegistry`` uses the created instance:: | |||
} | |||
} | |||
|
|||
Forms Using Validation | |||
------------------------------------ |
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.
please keep the underline as long as the title
); | ||
} | ||
|
||
// ... your tests | ||
} | ||
|
||
It is also possible to load custom form types, form type extensions or type guessers using the | ||
``getTypedExtensions``, ``getTypes`` and ``getTypeGuessers`` methods. |
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.
This should be part of a separate pull request as we will have to merge it into the master
branch (the rest can be merged into the docs for Symfony 2.7).
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.
One thing I forgot: Can you also add a versionadded
directive that mentions the introduction of the new methods?
…ons during unit testing (pierredup) This PR was squashed before being merged into the 3.3-dev branch (closes #21780). Discussion ---------- [DX] [Form] Add helper method to register form extensions during unit testing | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | N/A | License | MIT | Doc PR | symfony/symfony-docs#7578 Add helper method to register form extensions during unit testing, so it's easier to register custom form type extensions, form types, or type guessers Commits ------- bab562a [DX] [Form] Add helper method to register form extensions during unit testing
…ons during unit testing (pierredup) This PR was squashed before being merged into the 3.3-dev branch (closes #21780). Discussion ---------- [DX] [Form] Add helper method to register form extensions during unit testing | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | N/A | License | MIT | Doc PR | symfony/symfony-docs#7578 Add helper method to register form extensions during unit testing, so it's easier to register custom form type extensions, form types, or type guessers Commits ------- bab562a987 [DX] [Form] Add helper method to register form extensions during unit testing
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.
Thanks for that PR! Can you please separate the changes as @xabbuh asked?
form/unit_testing.rst
Outdated
Forms Using Validation | ||
---------------------- | ||
|
||
If your forms uses the ``invalid_message`` or ``constraints`` option for validation, you need to |
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.
It should either be If your form uses
or If your forms use
.
form/unit_testing.rst
Outdated
---------------------- | ||
|
||
If your forms uses the ``invalid_message`` or ``constraints`` option for validation, you need to | ||
register the validation extension which provides this options. |
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.
this
=> these
form/unit_testing.rst
Outdated
|
||
If your forms uses the ``invalid_message`` or ``constraints`` option for validation, you need to | ||
register the validation extension which provides this options. | ||
Luckily Symfony provides a custom test class which does this for you. |
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.
I would suggest Luckily Symfony provides a base test class which takes care of it, just extend [class].
And get rid of the following sentence, what do you think?
form/unit_testing.rst
Outdated
:class:`Symfony\\Component\\Form\\Tests\\Extension\\Validator\\Type\\TypeTestCase` | ||
class:: | ||
|
||
// tests/AppBundle/Form/Type/TestedTypeTests.php |
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.
Please remove the last s
in TestedTypeTest.php
.
I created a separate PR for 2.7 #7587. When that is merged, it should squash this diff to only leave the sentence for the new methods added symfony/symfony#21780 (I'll just resolve any conflicts there might be after that PR is merged) |
I removed the validator extension part in this docs, so it's not dependent on other changes, and can be merged to document the new methods added |
form/unit_testing.rst
Outdated
@@ -199,6 +199,9 @@ allows you to return a list of extensions to register:: | |||
It is also possible to load custom form types, form type extensions or type guessers using the | |||
``getTypedExtensions``, ``getTypes`` and ``getTypeGuessers`` methods. | |||
|
|||
.. versionadded:: 3.3 | |||
The ``getTypedExtensions``, ``getTypes`` and ``getTypeGuessers`` was introduced in Symfony 3.3. |
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.
"The [...] methods were introduced [...]."
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.
👍
Thank you @pierredup. FYI, I have taken the proposed changes from symfony/symfony#22445 taken into account in 68bcaa0. |
Docs for symfony/symfony#21780 to register custom extensions and types