News Feed
Sections




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

Jani Hartikainen's Blog:
Unit testing 4 Mock objects and testing code which uses the database
June 29, 2009 @ 11:43:14

Jani Hartikainen has posted the fourth part of his unit testing series looking at using mock objects when testing database interfaces.

When testing a class which needs an instance of another class to work, you do not want to depend on the other class too much. This is where mock objects come in - a mock object is a "clone" of an object, which we can use to simplify our tests, by having the mock object perform assertions or by replacing some functionality of the mock with our custom functionality.

He introduces some of the basics of mocking objects and how to create mock objects with PHPUnit. He takes it up to the next level with a mock database example based on grabbing event details to return "fake" results from a sample dataset.

0 comments voice your opinion now!
database unittest object mock


blog comments powered by Disqus

Similar Posts

NetTuts.com: Testing Like a Boss in Laravel: Models

KillerPHP.com: The Zend Framework: Writing Object-Oriented PHP with Ease

NetTuts.com: How to Write Testable and Maintainable Code in PHP

Milw0rm.com: Exploit - PHP5 COM Object Security Bypass (Windows)

Geeks Not Nerds Blog: Rolling your own Blog Backend from Scratch Part 1


Community Events





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


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

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