4

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
  • You question is a bit misleading. It sound's like you are facing the problem how to make unit tests for database related apps ? Good question, very good question :-) Commented Sep 2, 2010 at 6:53

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.