Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37200 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17976 invoked from network); 23 Apr 2008 12:11:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Apr 2008 12:11:11 -0000 Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 64.233.166.176 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 64.233.166.176 py-out-1112.google.com Received: from [64.233.166.176] ([64.233.166.176:26933] helo=py-out-1112.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 6D/94-29761-D572F084 for ; Wed, 23 Apr 2008 08:11:10 -0400 Received: by py-out-1112.google.com with SMTP id u77so2508091pyb.16 for ; Wed, 23 Apr 2008 05:11:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=tZYNgEHQVrYUX/scjI90bft57plqx2rSt0rQn9P/xd0=; b=FDD+lUtPBJWtC/vsHZy3YCi9LVDsf/gZ0fKzqN7sMtsCpzjBw+vOqisEWfhzDnXfxoLX6Ry9V34V+Dji7jvXZeim2XQFRNukyMxUcfpjAAo3VV0UDj8g+o8w58a5G52/R4TM7UcX/Kf9w+qoq+uE/rm9ZbFBoedr8cjSKAccn7w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=U7/eK1xlsNg/NoSx5+KE+1wi8snlSYdCOuxgXHmpR0p/f1OKubR+8c1/o+rf+MZXQpbLj0/b0DUr6+vg7oN+xtc+SEHXSs9GcH5gse/Zk99FoPPEdqvD3+i0J9LJlwq0m3WaJ8pny5CDGqloMKCwHuWd9v50UbOa73Eq+iJyzeI= Received: by 10.140.251.1 with SMTP id y1mr378027rvh.292.1208952666497; Wed, 23 Apr 2008 05:11:06 -0700 (PDT) Received: by 10.141.123.13 with HTTP; Wed, 23 Apr 2008 05:11:06 -0700 (PDT) Message-ID: Date: Wed, 23 Apr 2008 14:11:06 +0200 To: "Piotr Czachur" Cc: internals@lists.php.net In-Reply-To: <299f97600804230435o6bbf8eb2l9ca760458b949dd6@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <299f97600804230435o6bbf8eb2l9ca760458b949dd6@mail.gmail.com> Subject: Re: [PHP-DEV] Unable to unit test code containing *_uploaded_file() From: pierre.php@gmail.com ("Pierre Joye") On Wed, Apr 23, 2008 at 1:35 PM, Piotr Czachur 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