Skip to content

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

Closed
wants to merge 3 commits into from

Conversation

pierredup
Copy link
Contributor

@pierredup pierredup commented Mar 6, 2017

Docs for symfony/symfony#21780 to register custom extensions and types

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
Copy link
Contributor

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)

@@ -156,12 +156,31 @@ make sure the ``FormRegistry`` uses the created instance::
}
}

Forms Using Validation
------------------------------------
Copy link
Contributor

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.
Copy link
Member

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).

Copy link
Member

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?

fabpot added a commit to symfony/symfony that referenced this pull request Mar 6, 2017
…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
symfony-splitter pushed a commit to symfony/form that referenced this pull request Mar 6, 2017
…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
Copy link
Contributor

@HeahDude HeahDude left a 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?

Forms Using Validation
----------------------

If your forms uses the ``invalid_message`` or ``constraints`` option for validation, you need to
Copy link
Contributor

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.

----------------------

If your forms uses the ``invalid_message`` or ``constraints`` option for validation, you need to
register the validation extension which provides this options.
Copy link
Contributor

Choose a reason for hiding this comment

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

this => these


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.
Copy link
Contributor

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?

:class:`Symfony\\Component\\Form\\Tests\\Extension\\Validator\\Type\\TypeTestCase`
class::

// tests/AppBundle/Form/Type/TestedTypeTests.php
Copy link
Contributor

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.

@pierredup
Copy link
Contributor Author

pierredup commented Mar 7, 2017

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)

@pierredup pierredup changed the title Add docs about the validator TypeTestCase class Add docs to register custom form extensions and types for unit testing Mar 8, 2017
@pierredup
Copy link
Contributor Author

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

@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

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

"The [...] methods were introduced [...]."

@HeahDude HeahDude added the Form label Mar 10, 2017
Copy link
Contributor

@HeahDude HeahDude left a comment

Choose a reason for hiding this comment

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

👍

@xabbuh xabbuh closed this in 8421e72 Apr 15, 2017
xabbuh added a commit that referenced this pull request Apr 15, 2017
@xabbuh
Copy link
Member

xabbuh commented Apr 15, 2017

Thank you @pierredup. FYI, I have taken the proposed changes from symfony/symfony#22445 taken into account in 68bcaa0.

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.

7 participants