According to the Docs, SimpleTest has support for FileUpload testing baked in since version 1.0.1:
File upload testing Can simulate the input type file tag 1.0.1
I've looked over the examples at their site and would assume you'd use something along the lines of
$this->get('http://www.example.com/');
$this->setField('filename', 'local path');
$this->click('Go');
to submit the file and then use the regular assertions to check the upload worked as wanted. But that's really just a wild guess, since I am not familiar with SimpleTest and I couldnt find an example at their homepage. You might want to ask in their support forum though.
But basically, there is not much use testing that a form uploads a file. This is tried and tested browser behavior. Testing the code that handles the upload makes more sense. I dont know how you implemented your FileUpload code, but if I had to implement this, I would get rid of the dependency on the $_FILES
array as the first thing. Create a FileRequest
class that you can pass the $_FILES
array to. Then you can handle the upload from the class. This would allow you to test the functionality without actually uploading a file. Just setup your FileRequest instance accordingly. You could even mock the filesystem with vfsStreamWrapper, so you dont even need actual files.