News Feed
Sections




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

Ryan Mauger's Blog:
Controller Testing with the FlashMessenger in Zend Framework
March 16, 2012 @ 11:55:53

Ryan Mauger has a new post to his blog today looking at doing some controller testing in a Zend Framework application and some issues he was with the FlashMessenger component.

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.

He includes the code to mock out the FlashMessenger component and expose the "addMessage" method. In his first test, the assertion is that this method is never called (failure if it is) and in the second, it should only be called once.

0 comments voice your opinion now!
zendframework unittest phpunit flashmessenger mockobject


blog comments powered by Disqus

Similar Posts

Cal Evans' Blog: Zend's new namespace converter

Pádraic Brady's Blog: Having a bad ViewRenderer day in your ZF app?

Brian DeShong's Blog: Zend_Log_Writer_Mail: "Ready for Recommendation"

Vinu Thomas' Blog: Quicker and cleaner Form using Zend Form

MaltBlue.com: Zend Form Mastery with Zend_Config - Part 2, Core Form Configuration


Community Events





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


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

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