RE: [PHP-DEV] Unable to unit test code containing *_uploaded_file()
| From: | Jared Williams | Date: | Wed, 23 Apr 2008 14:04:39 +0000 |
| Subject: | RE: [PHP-DEV] Unable to unit test code containing *_uploaded_file() | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-37204@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Piotr Czachur [mailto:zimnyx@gmail.com]
> Sent: 23 April 2008 12:36
> To: internals@lists.php.net
> Subject: [PHP-DEV] Unable to unit test code containing
> *_uploaded_file()
>
> Hello!
>
> I use PHPUnit for unit testing of my application (but this
> issue is independent of PHPUnit). Tests are run from command
> line so it's not way (that I can imagine) to simulate file
> upload, because app code uses is_uploaded_file() to check if
> file was really uploaded.
> In my opionion some functions for simulation of file upload
> in command line script would be very handy for unit testing.
>
> What I mean is adding a function or a set of functions for
> setting file upload, for example:
> do_file_upload( upload_params, upload data).
>
> This function would be for use only in testing code, so there
> would be no need to change existing application code to add
> unit tests, and what's more important it would not leak to
> security risk.
>
> Regards,
> Piotr Czachur
>
As of 1.0.1, SimpleTest's WebTester can upload files, I believe.
Jared