I have a quick question on the best approach to testing Zend_Form classes
that have Zend_Form_Element_File in them.
I have constructed a small test that shows what i am trying to do. In this
test the file element is optional so we not goig to provide a value for
The test is checking if we can process a valid submission:
public function testCanProcessValidSubmission()
$form = new Zend_Form();
//Add text field
$username = new Zend_Form_Element_Text('username');
//Add file field
$file = new Zend_Form_Element_File('image');
$file->setLabel('Upload an image:');
//Prepare form data
$formData = array();
$formData['username'] = 'Test user name';
$result = $form->isValid($formData);
//Assert validation passed
The form is working fine from the browser, i just whant to programmatically
test it for accepting valid data submission but that always fails.
I guess that has something to do with the global $_FILES array - just no
idea how should we alter that for testing.
David Mintz wrote
Have you dumped $form->getMessages() to see what's failing?