PHPUnit database testing with DBUnit extension
Hey, Im new to the whole PHPUnit and would like to test my code against a database, from reading all the stuff on the phpunit.de, it talks about a seed.xml 开发者_开发技巧file.
Can someone just clarify, do i need to create this dataset myself using a mysqldump command, or does it create it for me at the beginning of the test?
Many thanks in advance
I am just now researching this myself and came across this blog post:
http://matthewturland.com/2010/01/04/database-testing-with-phpunit-and-mysql/
So if you choose to accept the PHPUnit >= 3.5.0 requirements, you can use
mysqldump --xml -t -u username -p database
to create seed.xml and then load it as a dataset for DBUnit with
$dataSet = $this->createMySQLXMLDataSet('/path/to/seed.xml');
精彩评论