On Wed, Apr 23, 2008 at 1:35 PM, Piotr Czachur <[EMAIL PROTECTED]> wrote:

>  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.

See runtests and the respective phpt tests in the php releases or in
cvs (php-src module). It is possible to emulate file upload using the
CGI sapi (I'm not sure if we have tests using this feature). It is
even possible to emulate almost all http behavior (from a server point
of view) with it.

However, as far as I remember phpunit does not "fork" php and uses the
current instance and that will not allow you to use the phpt method.
If it is not the case, then it should be relatively easy to port the
phpt system to phpunit (or use phpt :).

It is not the ideal solution if you use phpunit, but it may already
give you something to test or use.

Cheers,
-- 
Pierre
http://blog.thepimp.net | http://www.libgd.org

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to