Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37199 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 9568 invoked from network); 23 Apr 2008 11:54:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Apr 2008 11:54:36 -0000 Authentication-Results: pb1.pair.com header.from=indeyets@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=indeyets@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.46.29 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: indeyets@gmail.com X-Host-Fingerprint: 74.125.46.29 yw-out-2324.google.com Received: from [74.125.46.29] ([74.125.46.29:40785] helo=yw-out-2324.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4E/C2-29761-B732F084 for ; Wed, 23 Apr 2008 07:54:35 -0400 Received: by yw-out-2324.google.com with SMTP id 5so92039ywh.83 for ; Wed, 23 Apr 2008 04:54:32 -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=Ef+Nojf1AGm5hj6gP9L6nIcxXQ9sdMonTkScut+JhbU=; b=HjXPJoxbdZWC0QzLHzwOSmDhsXMyRF6Jt97kVhvykp5LgszhAZGuiyamoUcNcuxYY7TQaTDHDVfWC1cdpF+reeulxLAQKRSVrRNn8SsfK3rvKnba3Qd3k2uMTBWgj+BDm18ulhk9HYnI0eW1tGQRoNPSBp+zEt6/ND13SuhUDpU= 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=mEDo5be1WW+LgnLymQ6hepetV6VcVYQMw3gkF0z0a0+YZgM/g2eXRsuKb4G9g5geBHz0DvsgHPmCVpuzYonlP9xT+ORvSMpsN8HXr+iAUnVpBnRz+P6im1Ej+HFU7xclXOtuq8zqs3ECPcNRlsabetfvplOB8X7FxBJdXaiBels= Received: by 10.150.189.9 with SMTP id m9mr341453ybf.73.1208951672837; Wed, 23 Apr 2008 04:54:32 -0700 (PDT) Received: by 10.150.52.9 with HTTP; Wed, 23 Apr 2008 04:54:32 -0700 (PDT) Message-ID: Date: Wed, 23 Apr 2008 15:54:32 +0400 To: "Piotr Czachur" Cc: internals@lists.php.net In-Reply-To: <299f97600804230435o6bbf8eb2l9ca760458b949dd6@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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: indeyets@gmail.com ("Alexey Zakhlestin") On Wed, Apr 23, 2008 at 3:35 PM, Piotr Czachur wrote: > 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. you can write custom extension for such purposes. or you can try to separate logical part of your code, from the part, which interacts with file-uploading and unit-test the logical part -- Alexey Zakhlestin http://blog.milkfarmsoft.com/