|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
HTML_QuickForm made testable using PHPUnit
I was looking through the HTML_QuickForm package content and saw, that there is no test cases. I was interested in seeing how to do a testcase using
HTML_QuickForm, because I want to put my forms (and especially the rules added to the forms) though a PHPUnit test. However, I cannot seem to find out how to submit the form with a simple php-code. php Code:
Now I was looking for a way to put it into a test case - I guess I could just set the defaults, and then submit it, but I don't see any way to do that. Can anybody help me out? The test would go something like this - but it will not work until the form is submitted somehow. |
|
#2
|
|||
|
|||
|
RE: HTML_QuickForm made testable using PHPUnit
$form->validate() checks the values in $_POST, which means that you need to submit the form before you use such an assert call.
You might want to have a look at HTTP_Client or another package with a similar goal to simulate the submission. |
|
#3
|
|||
|
|||
|
RE: HTML_QuickForm made testable using PHPUnit
It was actually prettye easy, it turned out. I just had to populate the $_POST array, and then I could check the validate function.
|
|
#4
|
|||
|
|||
|
RE: RE: HTML_QuickForm made testable using PHPUnit
Quote:
That works, of course, but it isn't very realistic, especially when rules and filters are involved. For basic cases this is enough, though. |
|
#5
|
|||
|
|||
|
RE: HTML_QuickForm made testable using PHPUnit
Well, yes it is not the most realistic. However, I could not quite find out how to do the post using HTTP_Client::post(), as it requires an url to be specified!
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PEAR Packages > HTML_QuickForm made testable using PHPUnit |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|