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

Pro-PHP Podcast: Interview With Cal Evans

Nay Pryce's Blog: "Dependency Injection" Considered Harmful

Reinhold Weber's Blog: From PHP to Ruby - 30 similarities and differences

EllisLab.com: EllisLab Seeking New Owner for CodeIgniter

Henri Bergius\' Blog: Interested in the Zend PHP Framework


Community Events





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


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

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