News Feed
Sections




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

Carl Vuorinen:
Controller testing with database fixtures in Zend Framework
November 05, 2012 @ 12:44:31

Carl Vuorinen has a recent post to his site showing you how to unit test your Zend Framework (v1) controllers with the help of database fixtures to provide the test with valid data.

So I started thinking that there must be a way to use fixtures for the database the same way as when testing models with PHPUnit Database extension (PHPUnit_Extensions_Database_TestCase). But since PHP does not have multiple inheritance, we can't extend both Zend_Test_PHPUnit_ControllerTestCase and PHPUnit_Extensions_Database_TestCase. So I started out to create a controller test case class that has support for fixtures the same way as the database test case. I mean, how hard can it be?

He dug into the code for the extension and finally came up with a working solution - an abstract class with "_setup" and "_setupDatabase" methods that create what you'll need to perform your tests. A sample test is included in the post to show you it in action.

0 comments voice your opinion now!
zendframework controller testing database fixture


blog comments powered by Disqus

Similar Posts

Zend Developer Zone: Announcing February's ZF Bug Hunting Days

KillerPHP.com: Zend Framework Components - Part 1

Fabien Potencier's Blog: Create your own framework... on top of the Symfony2 Components (part 5)

Kevin Schroeder's Blog: Zend Framework 2 Event Manager

Community News: The Pipeline Project (MVC-based Framework)


Community Events





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


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

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