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

Mike Lively's Blog: Book Review: PHP5 CMS Framework Development by Martin Brampton

Dagfinn Reiersol's Blog: Don't refactor without unit tests

Jared White's Blog: Willowgarden Highlight: Easy Processing of Form Input

Mike Lively's Blog: Adding Database Tests to Existing PHPUnit Test Cases

Alexander Netkachev's Blog: Programming a data layer classes


Community Events





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


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

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