News Feed
Sections




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

DZone.com:
Testing PHP scripts
April 26, 2012 @ 10:50:24

In this new post to DZone.com, Giorgio Sironi talks about a method of testing that's non-invasive when you're in a chicken-and-egg kind of situation:

The legacy code dilemma, however, is always present: you can't refactor the code before putting up some tests on it to avoid regressions and putting your application offline. At the same time, you can't easily unit test the code until some refactoring is introduced.

He suggests making copies of some files to allow you to make small changes where needed to "mock" resources in the application to prevent it from accessing the actual data sources. His method fakes HTTP requests to the script and uses the copy of the script as an internal resource. Don't worry, code is included showing how its done - a basic "ForumPosting" class that includes the needed file and wraps the output in a buffer.

0 comments voice your opinion now!
testing unittest phpunit wrapper mock indirection


blog comments powered by Disqus

Similar Posts

Chris Hartjes: PHPSpec and the New Wave of Testing

Kevin Schroeder's Blog: ZendCon 2010 Podcast - Unit Testing in Zend Framework 1.8

Ben Ramsey: Learning a New Codebase

Sebastian Bergmann\'s Blog: PHPUnit Talk at PHP Usergroup Munich

Andi Gutmans' Blog: Zend Framework 1.6 Featuring Dojo, SOAP, Testing, and more...


Community Events

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


example programming project symfony yii2 composer series opinion laravel list interview application introduction framework php7 community language podcast api part2

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