views:

14

answers:

1

Hello

I recently got PHPUnit working with xDebug for testing my Zend Framework applications. The fact I use ZF shouldn't make any difference to this question- just mentioned it for completeness.

Anyway, it all works fine, but now I want to set up an in-memory database using PDO SQLite. I have done this successfully and have created tables and inserted data. However this task seemed to take ages, the syntax from my Export did not match SQLites needs so I had to play around for a while.

Also SQLite does not support constraints (is that right?) which my application does use, so the whole process seems a waste of time if I cannot test my constraints.

Is using SQLite the right solution to my problem? Does anyone have any better ways of using it or any other DB solution to unit testing?

+1  A: 

The idea of unit tests is to test smaller parts, so one way could be to work with small amounts of (static) sample data, for example as described in http://www.phpunit.de/manual/3.4/en/database.html

If you really need to test against a full database with all it's constraints, I think there is no way around just using the specific database of your application, for example MySQL.

Alex
Good point. I think I need to think about this differently. Stop trying to test my 'application' and start trying to test parts of it. To be honest using Zend has actually lead to this because of the way you can test it's MVC set up using PHPUnit.
jakenoble