Ryan Mauger shows how to do Controller Testing with the FlashMessenger in Zend Framework

March 22, 2012

News

PHP luminary Ryan Mauger posted an interesting article recently…well, interesting to Zend Framework developers. The post, titled “Controller Testing with the FlashMessenger in Zend Framework” describes a problem that Mauger ran into while writing unit tests and how he solved it.

During a recent project, I encountered problems with the flash messenger not playing ball with PHPUnit. The problem, the FlashMessenger using a session namespace, and trying to start the session.

Additionally to this problem, how do you test that the flash message is set as you’d expect (or not as the case may be)

The answer to both of these problems, lies in the same solution. a Mock Object.

Mauger does a good job of laying out the problem and then showing the details of his solution. If you are working with Zend Framework and building unit tests, the article is worth a quick read.

If you are working with Zend Framework and not building unit tests, you are doing it wrong.

About Cal Evans

Many moons ago, at the tender age of 14, Cal touched his first computer. (We're using the term "computer" loosely here, it was a TRS-80 Model 1) Since then his life has never been the same. He graduated from TRS-80s to Commodores and eventually to IBM PC's. For the past 10 years Cal has worked with PHP and MySQL on Linux OSX, and when necessary, Windows. He has built on a variety of projects ranging in size from simple web pages to multi-million dollar web applications. When not banging his head on his monitor, attempting a blood sacrifice to get a particular piece of code working, he enjoys building and managing development teams using his widely imitated but never patented management style of "management by wandering around". Cal is currently based in Nashville, TN and is gainfully unemployed as the Chief Marketing Officer of Blue Parabola, LLC. Cal is happily married to wife 1.28, the lovely and talented Kathy. Together they have 2 kids who were both bright enough not to pursue a career in IT. Cal blogs at http://blog.calevans.com and is the founder and host of Day Camp 4 Developers

View all posts by Cal Evans

No comments yet.

Leave a Reply

You must be logged in to post a comment.