News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

QaFoo.com:
Testing file uploads with PHP
December 13, 2010 @ 13:53:24

On the QaFoo.com site Manuel Pichler has posted a new tutorial about using unit testing, specifically with PHPUnit (really ending up on phpt) to test and be sure that your file upload handling is working correctly.

A question I am asked on a regular basis is, how you can test a file upload with PHP. In this blog post, I take a precise look at this topic and show you how to test your file uploads from within your standard testing environment, using widely unknown testing framework for PHP.

He shows how to use a custom $_FILES superglobal to mimic the upload process noting, however, that this won't work due to possible file handling on the backend. His alternative is to use a phpt test to push a raw posted file to the application and then check the results. He then shows how to take these functioning tests and drop them back into PHPUnit via it's "PhpTestCase" handling. You can find full code examples here.

0 comments voice your opinion now!
testing unittest file upload phpunit phpt tutorial


blog comments powered by Disqus

Similar Posts

WebReference.com: Unary, Binary, and Ternary Operators in PHP

Vexxblog: How to convert/encode files to FLV using FFMPEG & PHP

Marcelo Gornstein's Blog: Writing PHP applications with Doctrine2 as ORM and Ding as DI container

Michelangelo van Dam's Blog: Quality Assurance on PHP projects - PHPUnit part 1

Sameer Borate's Blog: Accessing Amazon Product Advertising API


Community Events





Don't see your event here?
Let us know!


tips symfony list voicesoftheelephpant series api bugfix library deployment interview zendserver conference laravel framework release podcast language community introduction developer

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework