News Feed
Sections




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

Mike Lively's Blog:
Introducing Phake Mocking Framework
December 29, 2010 @ 08:40:27

Mike Lively has a new post to his blog today looking at a mocking framework he's developed to work hand in hand with PHPUnit to make mocking easier and more robust.

I have used PHPUnit heavily now for the last 4 years. As anyone that is heavily involved in writing Unit Tests knows, test doubles (commonly referred to as mock objects) are a necessary part of your toolbox. The mocking options that we used to have for PHP unit testing have traditionally been fairly limited and most all of them in some form or another were ports of JMock. The way PHP operates as well as some decisions made to more closely emulate how JMock does things lead to functionality in the existing mock library for PHPUnit that for some are a hassle.

To help eliminate this hassle, he create the Phake mocking framework - a tool that comes at mocking a different way than the normal PHPUnit procedures. He includes some sample code for a class to test, a simple stub for getting a value and how to use it in a basic test. By calling a "Phake::mock()" on the class to make an object, you can call the method and run a "verify()" to ensure that the results are correct. He talks about some other options that the mocking allows too like calling a "no interaction" method on a mock and argument capturing.

0 comments voice your opinion now!
mock framework unittest phake github phpunit


blog comments powered by Disqus

Similar Posts

Paul Jones' Blog: Interview Tip: Avoid Mentioning PHP Frameworks

Phil Sturgeon's Blog: Why CodeIgniter HTML helper functions rock

Michelangelo van Dam's Blog: Quality Assurance on PHP projects - PHPUnit part 3

Mike Naberezny\'s Blog: Zend Framework Manual Updated

Matthew Weier OPhinney's Blog: State of Zend Framework 2.0


Community Events





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


laravel series conference development release podcast zendserver introduction language api tips framework community list bugfix code deployment interview voicesoftheelephpant symfony

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