I have a MySQL file that represents my database in a specific state that would allow me to test a class I am working on. What I want to do is have PHPUnit clean and rebuild the database from this file for each test or set of tests.
How can I go about that without having to resort to rew开发者_如何学运维riting the data in the XML format that PHPUnit uses?
I usually maintain a bootstrap.php file that handles dependency injection and calling a db.sql file. I call that each time one of my PHPUnit suites are called.
For row-specific changes, I tend to put those in my __construct() method for the unit test or in my individual test case methods. That way it's easier to track them if I need to change them.
Hope that helps a little.
精彩评论