Unit testing HTML_QuickForm2 forms
| From: | Christian Weiske | Date: | Tue, 05 Jul 2011 06:27:29 +0000 |
| Subject: | Unit testing HTML_QuickForm2 forms | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-31154@lists.php.net to get a copy of this message | ||
Hi,
I'm writing unit tests for my QF2 form validation rules and do it like
this:
$form = new My_Foo_Form(); //extends HTML_QuickForm2
$form->addBarFields();
$form->addDataSource(
new HTML_QuickForm2_DataSource_Session(
array(
'fieldname' => 'fieldvalue'
)
)
);
$this->assertFalse($form->validate());
$this->assertEquals(
'field needs to be a valid email',
$form->getElementById('fieldID')->getError()
);
Is there a better/different way to do it?
--
Regards/Mit freundlichen Grüßen
Christian Weiske
-= Geeking around in the name of science since 1982 =-