-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
A cookbook article on how to test forms #2012
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
A cookbook article on how to test forms #2012
Conversation
============= | ||
|
||
The form component itself consists of 3 core objects: the FormType, the | ||
Form and the FormView. |
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.
You should create links to the API documentation for objects as described in the documentation: http://symfony.com/doc/current/contributing/documentation/format.html#adding-links
Thanks for the comments @wouterj. I've updated the article according to them. |
Testing forms | ||
============= | ||
|
||
The form component itself consists of 3 core objects: a FormType (extending |
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.
remove itself
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.
A uppercase
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.
Why the uppercase?
Thanks @cordoval! I've updated the text according to your comments. IMHO the A in "The form component consists of 3 core objects: a FormType, the Form and the FormView" should stay in lowercase so I didn't change it. |
============= | ||
|
||
The form component consists of 3 core objects: a FormType (extending | ||
:class:`Symfony\\Component\\Form\\AbstractType`), 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.
Actually, you don't need to extend from AbstractType, only to implement the FormTypeInterface. Extending from AbstractType is only a way to avoid redefining empty methods each time when you don't need to customize all of them
good job 👍 👍 |
Testing forms | ||
============= | ||
|
||
The form component consists of 3 core objects: a FormType (extending |
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.
dad always said after a colon always upper case
the same as mama always said flush after creating an object
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 prefer to capitialize form component
(it should become The Form Component
)
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.
@cordoval maybe it's because I'm not a native English speaker, but I've never heard of this rule. Could you provide any grammar resource that discusses it? If it's right, we should also correct the rest of the documentation, there are many entries where it is not respected.
I've pushed some updates. I guess the changes will be easier to follow if I'll keep doing commits and then squash it when it's ready to merge. |
$form = $this->factory->create($type); | ||
|
||
$object = new TestObject(); | ||
$object->fromArray($formData) |
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.
missing semi-colon
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.
fixed
Hi Marek! Sorry for the delay on this - it's a very very nice entry - I think you could learn a lot about forms in general by reading it. I've merged this into the 2.1 branch and made a few minor changes at sha: Marek Thanks! |
Hi Ryan! That's some great news, I've already thought the article didn't have enough of support to be merged. Thank you very much! |
I have created an issue about moving those test classes to their own namespace. It will be done in 2.3, meaning that we need to monitor that issue and change this article when it is merged. |
@weaverryan is there any reason why this isn't merged into the 2.0 branch? |
@wouterj The article is not Symfony2.0 compilant. I don't remember the exact reasons, but I uses some SF2.1 functionalities. IMHO, the 2.0 is not supported anyway, so it's not worth adapting it. |
As requested by @johnkary a Cookbook version of my article from Theodo Blog (http://www.theodo.fr/blog/2012/11/symfony-testing-patterns-forms/).
This is my first Cookbook article so all feedback is very much welcome!