使用 DBUnit 扩展进行 PHPUnit 数据库测试

发布于 2024-10-03 21:42:05 字数 161 浏览 1 评论 0原文

嘿, 我对整个 PHPUnit 很陌生,想根据数据库测试我的代码,通过阅读 phpunit.de 上的所有内容,它讨论了一个 Seed.xml 文件。

有人可以澄清一下,我是否需要使用 mysqldump 命令自己创建这个数据集,还是它在测试开始时为我创建它?

预先非常感谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拥有 2024-10-10 21:42:05

我现在正在自己研究这个问题,并发现了这篇博客文章:

http://matthewturland.com/2010/01/04/database-testing-with-phpunit-and-mysql/

因此,如果您选择接受 PHPUnit >= 3.5.0 要求,您可以用于

mysqldump --xml -t -u username -p database

创建seed.xml,然后将其加载为DBUnit的数据集

$dataSet = $this->createMySQLXMLDataSet('/path/to/seed.xml');

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');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文