Thanks Vladas,

but you use this File_Transfer_Adapter you created to the whole application
or just in the testing environment? I would like to use this new class like
some kind of Mock, and use the class only in the testing environment.

There is a way to do that?

2010/8/25 Vladas Diržys <[email protected]>

> Hi,
>
> file upload unit testing is a bit tricky.
> The way I solved this problem, was to create another File_Transfer_Adapter
> which removes 'Upload' validator from File element.
> I extend Zend_Form_Element_File as well, to be able easily to override the
> transfer adapter.
>
> --
> Best Regards,
> Vladas Diržys
>
> On Wed, Aug 25, 2010 at 16:07, anderson.ls <[email protected]>wrote:
>
>>
>> Hi, i'm having problems testing actions with Zend_Form_Element_File. My
>> test
>> function:
>>
>>    public function testImportRequestAction($file)
>>    {
>>    $this->request->setMethod('POST')
>>         ->setPost(array(
>>             'MAX_FILE_SIZE' => "2097152",
>>    ));
>>
>>    $_FILES = array('request' => array(
>>                "name" => "rsaRequest.pem",
>>                "type" => "text/plain",
>>                "tmp_name" => "/tmp/phpi17KBB",
>>                "error" => 0,
>>                "size" => filesize('/tmp/phpi17KBB'),
>>    ));
>>
>>    $this->dispatch('/caoper/requests/importrarequest');
>>
>>    ....
>>    }
>>
>> But the form validation always returns false without any error messages.
>> And
>> when i force the form to pass validation i get "The file 'request' was
>> illegal uploaded, possible attack".
>> --
>> View this message in context:
>> http://zend-framework-community.634137.n4.nabble.com/Zend-form-element-file-and-Zend-test-problems-tp2338296p2338296.html
>> Sent from the Zend Framework mailing list archive at Nabble.com.
>>
>
>


-- 
Anderson Luiz Silvério

[email protected]
[email protected]
skype: anderson.ls

Reply via email to