News Feed
Sections




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

Emran Hasan's Blog:
Using Mockery as a mocking framework with PHPUnit
March 26, 2012 @ 14:52:03

Emran Hasan has posted an introduction to using the Mockery mocking tool with PHPUnit for a more powerful, easier to use object mocking system.

A few days ago I was explaining mocking to a few colleagues. I came up with the following quick n dirty code to show them the elegance of Mockery as a mocking framework. The code is straight-forward: it checks the health of a server using a tiny heart beat script.

He provides both sides of the code - a simple "heartbeat" script that just responds with a JSON result, the class to consume it, a HTTP wrapper class that will be the target of the mock and his PHPUnit tests (testSystemIsOnlineWhenServiceRuns). You can see the use of the Mockery tool in this test.

0 comments voice your opinion now!
mockery framework mock object phpunit unittest


blog comments powered by Disqus

Similar Posts

CakeBaker: Use components from the Zend Framework with CakePHP

Davey Shafik's Blog: ZCEGuide.com Deadline Fast Approaching

Code2Learn.com: Generating CSV file using CodeIgniter Framework

ThePHP.cc: PHPUnit: Migration from PEAR to PHAR

Alexander Netkachev's Blog: Zend_Cache review


Community Events

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


podcast threedevsandamaybe extension language laravel5 voicesoftheelephpant unittest framework introduction series symfony laravel version api library opinion interview security release community

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