News Feed
Sections




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

Till Klampaeckel's Blog:
Debugging Zend_Test
September 22, 2010 @ 08:10:04

In a new post to his blog Till Klampaeckel looks at unit testing in a real life example he had when working with the Zend Framework's Zend_Test component.

If I have to spend too much time debugging a test it's usually a bad test. Which usually means that it's too complex. However, with Zend_Test_PHPUnit_ControllerTestCase, it's often not the actual test, but the framework. This is not just tedious for myself, it's also not the most supportive fact when I ask my developers to write tests. [...] The [details about the error] are especially tricky and drive me nuts on a regular basis because a unit test should never withhold these things from you. After all, we use these tests to catch bugs to begin with. Why make it harder for the developer fix them?

In his example he has a controller that validates API requests before the routing gets too far (preDispatch) and responds with a 401 HTTP code if they can't use it. His test, however, just fails and doesn't give any feedback on what happened over than "it's broken". To remedy the situation he uses something he's created, a Listener, that can be used as a part of the PHPUnit configuration and gives the output of the test including headers, HTTP response code and the body of the response - a much handier result.

0 comments voice your opinion now!
zendtest zendframework


blog comments powered by Disqus

Similar Posts

Community News: Packagist Latest Releases for 02.03.2014

IBM developerWorks: PHP frameworks, Part 1: Getting started with three popular frameworks

Community News: Recent posts from PHP Quickfix

International PHP Magazine: Which one of the following is the Best Function for MySQL Data Fetching

Padraic Brady's Blog: The Zend Framework and Microformats: Zend_Microformat Proposed


Community Events





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


opinion refactor series list developer unittest interview threedevsandamaybe framework language code install laravel release community testing introduction podcast symfony2 configure

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