<p>I am using SimpleTest, a PHP-based unit testing framework. I am testing new code that will handle storing and retrieving website comments from a database. I am at a loss for how to structure the project to test the database access code.</p>

<p>I am looking for any suggestions as to best practices for testing db code in a PHP application. Examples are really great. Sites for further reading are great.</p>

<p>Thank you kindly. :)</p>

I had a local database dedicated to unit testing with a known name and database username/password.  The unit tests were hard-coded to that location but different developers could override those variables if they wanted.
Then before each test you
```
TRUNCATE
```
each table.  This is
much
faster than dropping/creating tables or the database itself.
Note: Do
not
truncate after the tests!  That way if a test fails you have the current state of the database which often helps diagnose the problem.