开发者

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');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜