Wednesday, October 9, 2013

Re: Testing file uploads using SimpleTest web tests?

Hi Josh,

  Did you figure out the issue?

I am testing my php file using simpletest webtestcase.  The form has file type input where i upload files.  I wrote webtestcase like this:
$this->setField('file', 'path to filename');
$this->click('Submit');
$this->assertText('file uploaded successfully');

This doesn't accept the filename and shows the test case  fails  in output. Please let me know if anybody has done this before.

Thanks,
Kanaga

On Wednesday, October 6, 2010 10:07:08 AM UTC+1, psybear83 wrote:
Hi everybody

After suffering hours of debugging the problem that my upload form
worked great when used in Firefox and not working (being blackholed)
using SimpleTest web tests, I finally found the problem: SimpleTest
doesn't seem to recognize the file upload field, and so the
SecurityComponent::_validatePost() fails because when displaying the
form there is one more field than after submit, where the file field
is missing in the $data array.

I did some searching and found that SimpleTest should be able to
simulate file uploads:

"File upload testing - Can simulate the input type file tag" on
http://www.simpletest.org/api/SimpleTest/tutorial_SimpleTest.pkg.html

And here I found some API-information:
http://simpletest.org/api_1.0.1/SimpleTest/WebTester/SimpleUploadTag.html

But I didn't find any information on how to use this in practice.

So for now I deactivated validatePost for the action using

$this->Security->validatePost = false;

in the UsersController. But it would be great if anybody could help me
getting this to work using SimpleTest.

Thanks a lot
Josh

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: