News Feed
Sections




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

Konstantin Kudryashov:
Conceptual difference between Mockery and Prophecy
January 14, 2014 @ 10:47:20

In a new post to his site today Konstantin Kudryashov takes a look at two PHP testing tools and the differences/similarities between them - Mockery and Prophecy. Mockery is a mocking tool created by Pádraic Brady to make mocking simpler and Prophecy is more of a mocking framework, both for use in PHP unit testing.

Today I've been asked twice what's the difference between Mockery and Prophecy just to suddenly discover that I didn't clarify this aspect never before. Well, that's about time. If we were to remove all the syntactical and implementation differences between two libraries what we'll be left with is one really big conceptual difference and it's the fact that in contradiction to Mockery, Prophecy puts messaging (aka how objects communicate) before structure (aka when objects communicate).

He starts with a sample class (the usual "calculator" example) and shows how it would look to mock it out with each tool, setting return values for both the "getRating" and "setRating" methods. He enhances the tests a bit more to include an event dispatcher and raising an event. The approach is similar, but Prophecy uses something called "message binding" to more effectively handle changes to the class under test.

0 comments voice your opinion now!
difference mockery prophecy unittest mocking framework

Link: http://everzet.com/post/72910908762/conceptual-difference-between-mockery-and-prophecy

blog comments powered by Disqus

Similar Posts

Chad Minick: PHP frameworks are obsolete

The Bakery: Lots of New Articles/Tutorials/Components

Felix Geisendorfer's Blog: Controller Testing in CakePHP

Stuart Herbert\'s Blog: Zend Framework and the Contributor License Agreement

The Show: The Show Strikes Back!


Community Events





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


introduction voicesoftheelephpant composer community interview version podcast release tool library laravel update language security install framework series symfony opinion package

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