-- Charles Hoffman <[EMAIL PROTECTED]> wrote (on Thursday, 10 April 2008, 11:52 AM -0500): > It's my impression, or perhaps just my opinion, that there are a number > of methods to designing the "model" portion of a Zend MVC app, depending > on the complexity your project needs. So for example, you could just > have your controllers interact with various Zend_Db classes directly, or > have them interact with a domain model consisting of classes that either > extend, or wrap/delegate-to appropriate instances of Zend_Db_Table and > Zend_Db_Row classes. > > I'm trying to work out what the best methods would be to unit test this > model layer with PHPUnit, independently of a "real" database (or at > least, be able to quickly reset the database to a known state at the > start of each test). I need some advice on "best practices" or even > just "practices that have worked pretty well for me." > > Is it possible to create mock Zend_Db_Table and Zend_Db_Row classes that > extend Zend_Db_Table_Abstract and Zend_Db_Row_Abstract, but simply > operate on some in-memory data? Is that even a sensible way to try to > go about it? Better still, might there already be a framework for doing > this sort of thing? The less boilerplate I need to do just to run some > tests, the better.
I actually use the in-memory SQLite adapter for this sort of thing. Simply specify a 'dbname' of ':memory' for the sqlite or pdo_sqlite Zend_Db adapter, load your schema and some test data, and you're good to go. -- Matthew Weier O'Phinney Software Architect | [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
