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:
Record and replay for testing of legacy PHP applications
June 21, 2012 @ 10:43:09

In this new post to DZone.com Giorgio Sironi looks at a method for "recording" the request and response information for an application that might be lacking in documentation using PHP's output buffering.

So you've got this big ball of code. You don't even know how to call all of these scripts, but the code is in production and works just fine (until you have to change even a single line). How to define some characterization tests that describe how the .php scripts work now? [...] If tests do not exist, we do not know if they expect GET or POST requests, which parameters they contain, and above all what their response should be in correct and error cases. Even if all the links and calling code are under your control, it may be faster to go for the recording approach. If other applications and machines call your .php files, it is your only choice.

He suggests using ob_start and the output buffering methods to handle the recording as it lets us define a callback (or in his case, a recording object). He includes an abstract version of it, showing how to implement a "Tape" class and a "record" method to handle the data and push it into a log or some other recording mechanism.

0 comments voice your opinion now!
record tutorial legacy application outputbuffering


blog comments powered by Disqus

Similar Posts

Tobias Schlitt's Blog: A Two-day Look at PHPWeekender

DZone.com: Development Setup for Neo4j and PHP: Part 2

Andrew Podner: Lithium: Building Views Using Layouts

Fabien Potencier's Blog: Symfony Service Container: Using XML or YAML to describe Services

DZone.com: Record and replay for testing of legacy PHP applications


Community Events

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


series introduction extension video framework language opinion psr7 api laravel voicesoftheelephpant release library interview conference unittest laravel5 development community podcast

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