Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37210 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 64112 invoked from network); 24 Apr 2008 15:11:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Apr 2008 15:11:39 -0000 X-Host-Fingerprint: 195.16.58.126 unknown Received: from [195.16.58.126] ([195.16.58.126:2382] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 26/FC-30653-A23A0184 for ; Thu, 24 Apr 2008 11:11:39 -0400 Message-ID: <26.FC.30653.A23A0184@pb1.pair.com> To: internals@lists.php.net Date: Thu, 24 Apr 2008 19:11:32 +0400 User-Agent: Thunderbird 2.0.0.12 (X11/20080213) MIME-Version: 1.0 References: <299f97600804230435o6bbf8eb2l9ca760458b949dd6@mail.gmail.com> In-Reply-To: <299f97600804230435o6bbf8eb2l9ca760458b949dd6@mail.gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Posted-By: 195.16.58.126 Subject: Re: Unable to unit test code containing *_uploaded_file() From: max@maxantonov.name (Maxim Antonov) I think - you can write wrapper for file class file{ public function is_uploaded(){ return SingletonContextObject::isForTestingFileIsUpload() ||=20 is_uploaded_file($this->filepath); } } Piotr Czachur =D0=BF=D0=B8=D1=88=D0=B5=D1=82: > Hello! >=20 > 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. >=20 > 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). >=20 > 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. >=20 > Regards, > Piotr Czachur