News Feed
Sections




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

PHPBuilder.com:
PHPUnit Fundamentals Setting Up and Tearing Down a Doctrine 2 Database
August 18, 2011 @ 09:03:40

New on PHPBuilder.com today is a tutorial showing you how to use set up and tear down methods in PHPUnit unit tests to work with a Doctrine 2 database, making it simpler to run self-contained testing.

The recently released Doctrine 2 presents significant advantages over its 1.X predecessor, advantages which are even more pronounced when compared to the Zend Framework's default database solution, namely the Zend_Db component. [...] When running unit tests which vet various aspects of your database you'll want to setup (create) and teardown (destroy) the test database, ensuring that a pristine and repeatable version of the database is available to each test.

He includes an example of using the SchemaTool class (of Doctrine) to drop and recreate the schema from scratch with the end result of a clean working copy, ready to test from. He also includes an example of how to initialize the database with some default information using the PHPUnit database connection and a default set of fixtures (defined in YAML).

0 comments voice your opinion now!
phpunit unittest setup tear down doctrine2 database tutorial


blog comments powered by Disqus

Similar Posts

Phil Sturgeon: Testing and Contributing with Composer Packages

Slawek Lukasiewicz's Blog: Zend Framework: logging with Firebug and FirePHP

PHPMaster.com: Under the Hood of Yii's Component Architecture, Part 3

IBM developerWorks: A step-by-step guide to publishing your own PEAR channels

ServerGrove Blog: Symfony2 components overview: EventDispatcher


Community Events





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


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

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