News Feed
Jobs Feed
Sections




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

PHPMaster.com:
Bulletproofing Database Interactions with PHPUnit's Database Extension
April 10, 2012 @ 08:50:10

On PHPMaster.com today there's a new tutorial showing you how to test your application's interface with the database using "bulletproof" PHPUnit testing.

There's already a great article here that discusses Test Driven Development, but did you know that you can also test the code that interacts with your database? Especially if your application is data intensive, subjecting your CRUD code to a battery of tests is good practice that helps ensure that your application is working correctly. In this article you will be learning how to write database tests in PHP using PHPUnit and its database extension.

Included in the post is an example schema and an example of the seed data (defined as XML) for the testing to use as predictable data in its execution. His test class extends PHPUnit_Extensions_Database_TestCase (instead of the usual PHPUnit_Framework_TestCase) and a test for a basic "getArticles" method in his "IArticleDAO" class. By calling the "createXMLDataSet" method, the test loads in the pre-defined XML records and allows the correct evaluation of the assertions,

0 comments voice your opinion now!
phpunit unittest database load xml dataset tutorial


blog comments powered by Disqus

Similar Posts

Gonzalo Ayuso: Combining Zend Framework2 and Symfony2 components with Composer to build PHP projects

Mike Willbanks' Blog: Getting Started with Nginx and PHP-FPM

Stefan Mischook's Blog: PHP Video Tutorial: Functions

Nick Halstead's Blog: How to make AuctionAd$ dynamic with PHP

Mike Naberezny's Blog: Wrapping PHP Functions for Testability


Community Events











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


language podcast release symfony2 security example overview facebook introduction composer opinion framework code install package hack hhvm application component unittest

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