开发者

PHPUnit database testing with DBUnit extension

开发者 https://www.devze.com 2023-01-27 04:02 出处:网络
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.

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

精彩评论

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

关注公众号