News Feed
Sections




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

Mike Naberezny's Blog:
Wrapping PHP Functions for Testability
August 01, 2007 @ 15:28:00

Mike Naberezny has a new post today about one of the easiest ways he's found to "wrap up" those functions in your code that make the unit testing for your application break when you run it:

One of the problems that hampers the testability of PHP code is the coupling created by accessing all of the PHP global functions. This happens often because a large number of useful extensions are accessed only through global functions.

He gives the example of an LDAP connect script that, because it requires an external LDAP server to connect to and return a response from, would break the tests. His way around the problem is to use an extension versus just calling the object itself (code included) through a ExtensionProxy. Then, it's a simple matter of calling the proxy object with the type parameter for the function to be called and evaluating the response of the proxy instead of the actual call.

0 comments voice your opinion now!
unittest testing extension proxy tutorial unittest testing extension proxy tutorial


blog comments powered by Disqus

Similar Posts

PHPRiot.com: Geocoding with PHP and the Google Maps API

BarelyFitz.com: CSS Colors - Take Control Using PHP

DevShed: Creating a MySQL Abstraction Layer with Bridge Classes in PHP 5

Fabien Potencier's Blog: Create your own framework... on top of the Symfony2 Components (part 1)

Zend Developer Zone: OSCON Wrapup Day 1: And so it Begins


Community Events





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


framework zendserver deployment package install series symfony podcast opinion language release introduction interview list api tips community laravel update library

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