News Feed
Sections




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

QaFoo.com:
Mocking with Phake
March 13, 2013 @ 12:53:26

On the QaFoo blog today there's a new tutorial posted showing you how to make unit test mocks with Phake, a testing tool that works a bit differently that other options (PHPUnit's own mocking and Mockery).

The use of Mock and Stub Objects is an important skill to learn when using Test Driven Development (TDD). Mock objects allow you to replace dependencies of an object with lookalikes, much like crash test dummies are used during automobile safety tests so humans aren't harmed. [...] Using Mocks in PHPUnit tests means using the built-in MockObjects library for quite some years. In the last years two contenders emerged that can be used as optional dependencies in PHPUnit. [...] This blog post introduces Phake, because it works quite differently than both PHPUnit Mock Objects and Mockery.

They include a code example of how to create mocks with Phake, showing it's different approach to defining the mocked methods. They explain each part of the code, detailing the use of the "when", "thenReturn" and "verify" methods. You can find out more about Phake and see other examples in the project's documentation.

0 comments voice your opinion now!
mocking unittest phake library tutorial introduction


blog comments powered by Disqus

Similar Posts

PHPFreaks.com: PHP Security

IBM developerWorks: Cook up Web sites fast w/CakePHP, Part 1: Adding related information & services

DevShed: An Introduction to Simulating the Model-View-Controller Schema in PHP

Ed Finkler's Blog: Inspekt Project funded by OWASP

SitePoint PHP Blog: Message Queues: Comparing Beanstalkd, IronMQ and Amazon SQS


Community Events





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


bugfix tips deployment list zendserver interview library symfony developer language series opinion community podcast threedevsandamaybe release framework api laravel introduction

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